@bash-app/bash-common 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bash-app/bash-common",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Common data and scripts to use on the frontend and backend",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -2,11 +2,13 @@ import {DeleteObjectCommand, PutObjectCommand, S3Client} from "@aws-sdk/client-s
2
2
  import {getSignedUrl} from "@aws-sdk/s3-request-presigner";
3
3
  import {DeleteObjectCommandOutput} from "@aws-sdk/client-s3/dist-types/commands";
4
4
 
5
+ const BASE_64_IMAGE_REGEX = /^data:image\/\w+;base64,/;
5
6
 
6
7
  export class AwsS3Utils {
7
8
  static async uploadBase64String(base64Str: string, assetKey: string): Promise<string | undefined> {
8
- const blobData = new Blob([base64Str]);
9
- return AwsS3Utils.uploadFile(blobData, assetKey, 'text/plain');
9
+ const bufferData = Buffer.from(base64Str.replace(BASE_64_IMAGE_REGEX, ""), 'base64');
10
+ const blobData = new Blob([bufferData]);
11
+ return AwsS3Utils.uploadFile(blobData, assetKey, 'image/jpeg');
10
12
  }
11
13
 
12
14
  static async uploadFile(file: Blob, assetKey: string, mimetype: string): Promise<string | undefined> {