@webiny/app-file-manager-s3 5.38.1-beta.0 → 5.38.2-beta.0
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.
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { UploadedFile, UploadOptions } from "@webiny/app/types";
|
|
2
2
|
import { FileUploadStrategy } from "./index";
|
|
3
|
+
declare global {
|
|
4
|
+
interface File {
|
|
5
|
+
key?: string;
|
|
6
|
+
keyPrefix?: string;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
3
9
|
export declare class SimpleUploadStrategy implements FileUploadStrategy {
|
|
4
10
|
upload(file: File, { apolloClient, onProgress }: UploadOptions): Promise<UploadedFile>;
|
|
5
11
|
}
|
package/SimpleUploadStrategy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","SimpleUploadStrategy","_classCallCheck2","default","_createClass2","key","value","_upload","_asyncToGenerator2","_regeneratorRuntime2","mark","_callee","file","_ref","apolloClient","onProgress","response","getPreSignedPostPayload","wrap","_callee$","_context","prev","next","query","GET_PRE_SIGNED_POST_PAYLOAD","fetchPolicy","variables","data","size","name","type","sent","fileManager","error","console","Error","abrupt","Promise","resolve","reject","formData","window","FormData","Object","keys","fields","forEach","append","xhr","XMLHttpRequest","upload","addEventListener","event","loaded","total","percentage","open","url","send","onload","status","responseText","stop","_x","_x2","apply","arguments","exports"],"sources":["SimpleUploadStrategy.ts"],"sourcesContent":["import { UploadedFile, UploadOptions } from \"@webiny/app/types\";\nimport { GET_PRE_SIGNED_POST_PAYLOAD } from \"./graphql\";\nimport { FileUploadStrategy } from \"~/index\";\n\nexport class SimpleUploadStrategy implements FileUploadStrategy {\n async upload(file: File, { apolloClient, onProgress }: UploadOptions): Promise<UploadedFile> {\n // 1. GET PreSignedPostPayload\n const response = await apolloClient.query({\n query: GET_PRE_SIGNED_POST_PAYLOAD,\n fetchPolicy: \"no-cache\",\n variables: {\n data: {
|
|
1
|
+
{"version":3,"names":["_graphql","require","SimpleUploadStrategy","_classCallCheck2","default","_createClass2","key","value","_upload","_asyncToGenerator2","_regeneratorRuntime2","mark","_callee","file","_ref","apolloClient","onProgress","response","getPreSignedPostPayload","wrap","_callee$","_context","prev","next","query","GET_PRE_SIGNED_POST_PAYLOAD","fetchPolicy","variables","data","size","name","type","keyPrefix","sent","fileManager","error","console","Error","abrupt","Promise","resolve","reject","formData","window","FormData","Object","keys","fields","forEach","append","xhr","XMLHttpRequest","upload","addEventListener","event","loaded","total","percentage","open","url","send","onload","status","responseText","stop","_x","_x2","apply","arguments","exports"],"sources":["SimpleUploadStrategy.ts"],"sourcesContent":["import { UploadedFile, UploadOptions } from \"@webiny/app/types\";\nimport { GET_PRE_SIGNED_POST_PAYLOAD } from \"./graphql\";\nimport { FileUploadStrategy } from \"~/index\";\n\ndeclare global {\n interface File {\n key?: string;\n keyPrefix?: string;\n }\n}\n\nexport class SimpleUploadStrategy implements FileUploadStrategy {\n async upload(file: File, { apolloClient, onProgress }: UploadOptions): Promise<UploadedFile> {\n // 1. GET PreSignedPostPayload\n const response = await apolloClient.query({\n query: GET_PRE_SIGNED_POST_PAYLOAD,\n fetchPolicy: \"no-cache\",\n variables: {\n data: {\n size: file.size,\n name: file.name,\n type: file.type,\n key: file.key,\n keyPrefix: file.keyPrefix\n }\n }\n });\n\n const { getPreSignedPostPayload } = response.data.fileManager;\n if (getPreSignedPostPayload.error) {\n console.error(getPreSignedPostPayload);\n throw Error(getPreSignedPostPayload.error);\n }\n\n // 2. upload file to S3\n return new Promise((resolve, reject) => {\n const formData = new window.FormData();\n Object.keys(getPreSignedPostPayload.data.data.fields).forEach(key => {\n formData.append(key, getPreSignedPostPayload.data.data.fields[key]);\n });\n\n formData.append(\"file\", file);\n\n const xhr = new window.XMLHttpRequest();\n xhr.upload.addEventListener(\n \"progress\",\n event => {\n if (onProgress) {\n onProgress({\n sent: event.loaded,\n total: file.size,\n percentage: (event.loaded / file.size) * 100\n });\n }\n },\n false\n );\n xhr.open(\"POST\", getPreSignedPostPayload.data.data.url, true);\n xhr.send(formData);\n xhr.onload = function () {\n if (this.status === 204) {\n resolve(getPreSignedPostPayload.data.file);\n return;\n }\n\n reject(this.responseText);\n };\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAAwD,IAU3CC,oBAAoB;EAAA,SAAAA,qBAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAF,oBAAA;EAAA;EAAA,IAAAG,aAAA,CAAAD,OAAA,EAAAF,oBAAA;IAAAI,GAAA;IAAAC,KAAA;MAAA,IAAAC,OAAA,OAAAC,kBAAA,CAAAL,OAAA,oBAAAM,oBAAA,CAAAN,OAAA,IAAAO,IAAA,CAC7B,SAAAC,QAAaC,IAAU,EAAAC,IAAA;QAAA,IAAAC,YAAA,EAAAC,UAAA,EAAAC,QAAA,EAAAC,uBAAA;QAAA,WAAAR,oBAAA,CAAAN,OAAA,IAAAe,IAAA,UAAAC,SAAAC,QAAA;UAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;YAAA;cAAIR,YAAY,GAAAD,IAAA,CAAZC,YAAY,EAAEC,UAAU,GAAAF,IAAA,CAAVE,UAAU;cAAAK,QAAA,CAAAE,IAAA;cAAA,OAExBR,YAAY,CAACS,KAAK,CAAC;gBACtCA,KAAK,EAAEC,oCAA2B;gBAClCC,WAAW,EAAE,UAAU;gBACvBC,SAAS,EAAE;kBACPC,IAAI,EAAE;oBACFC,IAAI,EAAEhB,IAAI,CAACgB,IAAI;oBACfC,IAAI,EAAEjB,IAAI,CAACiB,IAAI;oBACfC,IAAI,EAAElB,IAAI,CAACkB,IAAI;oBACfzB,GAAG,EAAEO,IAAI,CAACP,GAAG;oBACb0B,SAAS,EAAEnB,IAAI,CAACmB;kBACpB;gBACJ;cACJ,CAAC,CAAC;YAAA;cAZIf,QAAQ,GAAAI,QAAA,CAAAY,IAAA;cAcN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AG,EAAE,IAAI,CAAC;gBAC7DT,GAAG,CAACU,IAAI,CAAClB,QAAQ,CAAC;gBAClBQ,GAAG,CAACW,MAAM,GAAG,YAAY;kBACrB,IAAI,IAAI,CAACC,MAAM,KAAK,GAAG,EAAE;oBACrBtB,OAAO,CAACtB,uBAAuB,CAACU,IAAI,CAACf,IAAI,CAAC;oBAC1C;kBACJ;kBAEA4B,MAAM,CAAC,IAAI,CAACsB,YAAY,CAAC;gBAC7B,CAAC;cACL,CAAC,CAAC;YAAA;YAAA;cAAA,OAAA1C,QAAA,CAAA2C,IAAA;UAAA;QAAA,GAAApD,OAAA;MAAA,CACL;MAAA,SAAAwC,OAAAa,EAAA,EAAAC,GAAA;QAAA,OAAA1D,OAAA,CAAA2D,KAAA,OAAAC,SAAA;MAAA;MAAA,OAAAhB,MAAA;IAAA;EAAA;EAAA,OAAAlD,oBAAA;AAAA;AAAAmE,OAAA,CAAAnE,oBAAA,GAAAA,oBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-file-manager-s3",
|
|
3
|
-
"version": "5.38.
|
|
3
|
+
"version": "5.38.2-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
"author": "Webiny Ltd",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@webiny/app": "5.38.
|
|
13
|
+
"@webiny/app": "5.38.2-beta.0",
|
|
14
14
|
"graphql-tag": "2.12.6",
|
|
15
15
|
"p-retry": "4.6.2"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@babel/cli": "7.22.6",
|
|
19
19
|
"@babel/core": "7.22.8",
|
|
20
|
-
"@webiny/cli": "5.38.
|
|
21
|
-
"@webiny/project-utils": "5.38.
|
|
20
|
+
"@webiny/cli": "5.38.2-beta.0",
|
|
21
|
+
"@webiny/project-utils": "5.38.2-beta.0",
|
|
22
22
|
"rimraf": "3.0.2",
|
|
23
23
|
"typescript": "4.7.4"
|
|
24
24
|
},
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"build": "yarn webiny run build",
|
|
31
31
|
"watch": "yarn webiny run watch"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "443e107cc474882f558e0783a2d9068b7692bd00"
|
|
34
34
|
}
|