@webiny/api-file-manager-s3 5.23.1-beta.0 → 5.24.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.
- package/index.d.ts +1 -1
- package/package.json +7 -7
- package/plugins/fileStorageS3.d.ts +4 -1
- package/plugins/fileStorageS3.js +9 -5
- package/plugins/graphqlFileStorageS3.js +1 -2
- package/types.d.ts +16 -0
- package/types.js +5 -1
- package/utils/getPresignedPostPayload.d.ts +3 -10
- package/utils/getPresignedPostPayload.js +1 -0
- package/utils/uploadFileToS3.d.ts +4 -1
package/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: () => (import("@webiny/handler-graphql/types").GraphQLSchemaPlugin<import("@webiny/api-file-manager/types").FileManagerContext> | import("@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin").FilePhysicalStoragePlugin)[];
|
|
1
|
+
declare const _default: () => (import("@webiny/handler-graphql/types").GraphQLSchemaPlugin<import("@webiny/api-file-manager/types").FileManagerContext> | import("@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin").FilePhysicalStoragePlugin<import("@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin").FilePhysicalStoragePluginUploadParams, import("@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin").FilePhysicalStoragePluginDeleteParams>)[];
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-file-manager-s3",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.24.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"author": "Webiny Ltd",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@webiny/api-file-manager": "5.
|
|
14
|
-
"@webiny/handler-graphql": "5.
|
|
15
|
-
"@webiny/validation": "5.
|
|
13
|
+
"@webiny/api-file-manager": "5.24.0",
|
|
14
|
+
"@webiny/handler-graphql": "5.24.0",
|
|
15
|
+
"@webiny/validation": "5.24.0",
|
|
16
16
|
"form-data": "3.0.1",
|
|
17
17
|
"node-fetch": "2.6.7",
|
|
18
18
|
"sanitize-filename": "1.6.3",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@babel/cli": "^7.16.0",
|
|
23
23
|
"@babel/core": "^7.16.0",
|
|
24
|
-
"@webiny/cli": "^5.
|
|
25
|
-
"@webiny/project-utils": "^5.
|
|
24
|
+
"@webiny/cli": "^5.24.0",
|
|
25
|
+
"@webiny/project-utils": "^5.24.0",
|
|
26
26
|
"rimraf": "^3.0.2",
|
|
27
27
|
"typescript": "^4.1.3"
|
|
28
28
|
},
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"build": "yarn webiny run build",
|
|
35
35
|
"watch": "yarn webiny run watch"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "be0cbfcaa9247c658c44179af7943cc5d6d71bc7"
|
|
38
38
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import { FilePhysicalStoragePlugin } from "@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin";
|
|
1
|
+
import { FilePhysicalStoragePlugin, FilePhysicalStoragePluginUploadParams } from "@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin";
|
|
2
|
+
import { PresignedPostPayloadData } from "../types";
|
|
3
|
+
export interface S3FilePhysicalStoragePluginUploadParams extends FilePhysicalStoragePluginUploadParams, PresignedPostPayloadData {
|
|
4
|
+
}
|
|
2
5
|
declare const _default: () => FilePhysicalStoragePlugin;
|
|
3
6
|
export default _default;
|
package/plugins/fileStorageS3.js
CHANGED
|
@@ -21,13 +21,17 @@ const _excluded = ["settings", "buffer"];
|
|
|
21
21
|
const S3_BUCKET = process.env.S3_BUCKET;
|
|
22
22
|
|
|
23
23
|
var _default = () => {
|
|
24
|
+
/**
|
|
25
|
+
* We need to extends the type for FilePhysicalStoragePlugin.
|
|
26
|
+
* Otherwise the getPresignedPostPayload does not know it has all required values in params.
|
|
27
|
+
*/
|
|
24
28
|
return new _FilePhysicalStoragePlugin.FilePhysicalStoragePlugin({
|
|
25
|
-
upload: async
|
|
29
|
+
upload: async params => {
|
|
26
30
|
const {
|
|
27
31
|
settings,
|
|
28
32
|
buffer
|
|
29
|
-
} =
|
|
30
|
-
data = (0, _objectWithoutProperties2.default)(
|
|
33
|
+
} = params,
|
|
34
|
+
data = (0, _objectWithoutProperties2.default)(params, _excluded);
|
|
31
35
|
const {
|
|
32
36
|
data: preSignedPostPayload,
|
|
33
37
|
file
|
|
@@ -43,10 +47,10 @@ var _default = () => {
|
|
|
43
47
|
file
|
|
44
48
|
};
|
|
45
49
|
},
|
|
46
|
-
delete: async
|
|
50
|
+
delete: async params => {
|
|
47
51
|
const {
|
|
48
52
|
key
|
|
49
|
-
} =
|
|
53
|
+
} = params;
|
|
50
54
|
const s3 = new _s.default();
|
|
51
55
|
await s3.deleteObject({
|
|
52
56
|
Bucket: S3_BUCKET,
|
|
@@ -113,8 +113,7 @@ const plugin = {
|
|
|
113
113
|
const settings = await context.fileManager.settings.getSettings();
|
|
114
114
|
const promises = [];
|
|
115
115
|
|
|
116
|
-
for (
|
|
117
|
-
const item = files[i];
|
|
116
|
+
for (const item of files) {
|
|
118
117
|
promises.push((0, _getPresignedPostPayload.default)(item, settings));
|
|
119
118
|
}
|
|
120
119
|
|
package/types.d.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import S3 from "aws-sdk/clients/s3";
|
|
2
|
+
export interface PresignedPostPayloadData {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
size: number;
|
|
6
|
+
keyPrefix: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PresignedPostPayloadDataResponse {
|
|
9
|
+
data: S3.PresignedPost;
|
|
10
|
+
file: {
|
|
11
|
+
name: string;
|
|
12
|
+
key: string;
|
|
13
|
+
type: string;
|
|
14
|
+
size: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
package/types.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
file: {
|
|
5
|
-
name: string;
|
|
6
|
-
key: string;
|
|
7
|
-
type: any;
|
|
8
|
-
size: any;
|
|
9
|
-
};
|
|
10
|
-
}>;
|
|
1
|
+
import { PresignedPostPayloadData, PresignedPostPayloadDataResponse } from "../types";
|
|
2
|
+
import { FileManagerSettings } from "@webiny/api-file-manager/types";
|
|
3
|
+
declare const _default: (data: PresignedPostPayloadData, settings: FileManagerSettings) => Promise<PresignedPostPayloadDataResponse>;
|
|
11
4
|
export default _default;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Response } from "node-fetch";
|
|
3
|
+
import S3 from "aws-sdk/clients/s3";
|
|
4
|
+
declare const _default: (buffer: Buffer, preSignedPostPayload: S3.PresignedPost) => Promise<Response>;
|
|
2
5
|
export default _default;
|