Return correct file
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma
2021-03-02 16:51:16 +01:00
parent 2dd10f04a3
commit b000d5119a
2 changed files with 14 additions and 9 deletions

View File

@@ -21,9 +21,12 @@ export class ImageService {
return this.httpClient.put<any>(endpoint,formData);
}
b64toBlob(b64Data:string, contentType?:string):Blob {
dataUrltoBlob(dataURI:string):Blob {
var mime = dataURI.split( ';base64,')[0].split(':')[1];
var byteCharacters = atob(dataURI.split( ';base64,')[1]);
const sliceSize = 512;
const byteCharacters = atob(b64Data);
const byteArrays = [];
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
@@ -38,7 +41,11 @@ export class ImageService {
byteArrays.push(byteArray);
}
const blob = new Blob(byteArrays, {type: contentType});
const blob = new Blob(byteArrays, {type: mime});
return blob;
}
blobToFile(blob:Blob, filename:string):File {
return new File([blob],filename);
}
}