Skip to content

Commit

Permalink
fix: Fixed download JPEG image format
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Nov 23, 2020
1 parent bb7092e commit c88590f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/api/layers/profile.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,15 @@ export class ProfileLayer extends HostLayer {
let b64 = await downloadFileToBase64(path, [
'image/png',
'image/jpg',
'image/jpeg',
'image/webp',
]);
if (!b64) {
b64 = await fileToBase64(path);
}
if (b64) {
const buff = Buffer.from(
b64.replace(/^data:image\/(png|jpeg|webp);base64,/, ''),
b64.replace(/^data:image\/(png|jpe?g|webp);base64,/, ''),
'base64'
);
const mimeInfo = base64MimeType(b64);
Expand Down
4 changes: 3 additions & 1 deletion src/api/layers/sender.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class SenderLayer extends ListenerLayer {
let base64 = await downloadFileToBase64(filePath, [
'image/png',
'image/jpg',
'image/jpeg',
'image/webp',
]);

Expand Down Expand Up @@ -555,14 +556,15 @@ export class SenderLayer extends ListenerLayer {
let b64 = await downloadFileToBase64(path, [
'image/png',
'image/jpg',
'image/jpeg',
'image/webp',
]);
if (!b64) {
b64 = await fileToBase64(path);
}
if (b64) {
const buff = Buffer.from(
b64.replace(/^data:image\/(png|jpeg|webp);base64,/, ''),
b64.replace(/^data:image\/(png|jpe?g|webp);base64,/, ''),
'base64'
);
const mimeInfo = base64MimeType(b64);
Expand Down

0 comments on commit c88590f

Please sign in to comment.