@payloadcms/plugin-cloud-storage 3.12.1-canary.b1b1cbf → 3.13.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/package.json +3 -54
- package/dist/adapters/azure/generateURL.d.ts +0 -8
- package/dist/adapters/azure/generateURL.d.ts.map +0 -1
- package/dist/adapters/azure/generateURL.js +0 -6
- package/dist/adapters/azure/generateURL.js.map +0 -1
- package/dist/adapters/azure/handleDelete.d.ts +0 -10
- package/dist/adapters/azure/handleDelete.d.ts.map +0 -1
- package/dist/adapters/azure/handleDelete.js +0 -9
- package/dist/adapters/azure/handleDelete.js.map +0 -1
- package/dist/adapters/azure/handleUpload.d.ts +0 -11
- package/dist/adapters/azure/handleUpload.d.ts.map +0 -1
- package/dist/adapters/azure/handleUpload.js +0 -28
- package/dist/adapters/azure/handleUpload.js.map +0 -1
- package/dist/adapters/azure/index.d.ts +0 -14
- package/dist/adapters/azure/index.d.ts.map +0 -1
- package/dist/adapters/azure/index.js +0 -63
- package/dist/adapters/azure/index.js.map +0 -1
- package/dist/adapters/azure/staticHandler.d.ts +0 -10
- package/dist/adapters/azure/staticHandler.d.ts.map +0 -1
- package/dist/adapters/azure/staticHandler.js +0 -44
- package/dist/adapters/azure/staticHandler.js.map +0 -1
- package/dist/adapters/gcs/generateURL.d.ts +0 -9
- package/dist/adapters/gcs/generateURL.d.ts.map +0 -1
- package/dist/adapters/gcs/generateURL.js +0 -6
- package/dist/adapters/gcs/generateURL.js.map +0 -1
- package/dist/adapters/gcs/handleDelete.d.ts +0 -9
- package/dist/adapters/gcs/handleDelete.d.ts.map +0 -1
- package/dist/adapters/gcs/handleDelete.js +0 -10
- package/dist/adapters/gcs/handleDelete.js.map +0 -1
- package/dist/adapters/gcs/handleUpload.d.ts +0 -13
- package/dist/adapters/gcs/handleUpload.d.ts.map +0 -1
- package/dist/adapters/gcs/handleUpload.js +0 -18
- package/dist/adapters/gcs/handleUpload.js.map +0 -1
- package/dist/adapters/gcs/index.d.ts +0 -14
- package/dist/adapters/gcs/index.d.ts.map +0 -1
- package/dist/adapters/gcs/index.js +0 -55
- package/dist/adapters/gcs/index.js.map +0 -1
- package/dist/adapters/gcs/staticHandler.d.ts +0 -11
- package/dist/adapters/gcs/staticHandler.d.ts.map +0 -1
- package/dist/adapters/gcs/staticHandler.js +0 -45
- package/dist/adapters/gcs/staticHandler.js.map +0 -1
- package/dist/adapters/s3/generateURL.d.ts +0 -9
- package/dist/adapters/s3/generateURL.d.ts.map +0 -1
- package/dist/adapters/s3/generateURL.js +0 -6
- package/dist/adapters/s3/generateURL.js.map +0 -1
- package/dist/adapters/s3/handleDelete.d.ts +0 -9
- package/dist/adapters/s3/handleDelete.d.ts.map +0 -1
- package/dist/adapters/s3/handleDelete.js +0 -11
- package/dist/adapters/s3/handleDelete.js.map +0 -1
- package/dist/adapters/s3/handleUpload.d.ts +0 -13
- package/dist/adapters/s3/handleUpload.d.ts.map +0 -1
- package/dist/adapters/s3/handleUpload.js +0 -37
- package/dist/adapters/s3/handleUpload.js.map +0 -1
- package/dist/adapters/s3/index.d.ts +0 -24
- package/dist/adapters/s3/index.d.ts.map +0 -1
- package/dist/adapters/s3/index.js +0 -55
- package/dist/adapters/s3/index.js.map +0 -1
- package/dist/adapters/s3/staticHandler.d.ts +0 -11
- package/dist/adapters/s3/staticHandler.d.ts.map +0 -1
- package/dist/adapters/s3/staticHandler.js +0 -48
- package/dist/adapters/s3/staticHandler.js.map +0 -1
- package/dist/adapters/vercelBlob/generateURL.d.ts +0 -8
- package/dist/adapters/vercelBlob/generateURL.d.ts.map +0 -1
- package/dist/adapters/vercelBlob/generateURL.js +0 -8
- package/dist/adapters/vercelBlob/generateURL.js.map +0 -1
- package/dist/adapters/vercelBlob/handleDelete.d.ts +0 -9
- package/dist/adapters/vercelBlob/handleDelete.d.ts.map +0 -1
- package/dist/adapters/vercelBlob/handleDelete.js +0 -13
- package/dist/adapters/vercelBlob/handleDelete.js.map +0 -1
- package/dist/adapters/vercelBlob/handleUpload.d.ts +0 -10
- package/dist/adapters/vercelBlob/handleUpload.d.ts.map +0 -1
- package/dist/adapters/vercelBlob/handleUpload.js +0 -21
- package/dist/adapters/vercelBlob/handleUpload.js.map +0 -1
- package/dist/adapters/vercelBlob/index.d.ts +0 -37
- package/dist/adapters/vercelBlob/index.d.ts.map +0 -1
- package/dist/adapters/vercelBlob/index.js +0 -54
- package/dist/adapters/vercelBlob/index.js.map +0 -1
- package/dist/adapters/vercelBlob/staticHandler.d.ts +0 -9
- package/dist/adapters/vercelBlob/staticHandler.d.ts.map +0 -1
- package/dist/adapters/vercelBlob/staticHandler.js +0 -52
- package/dist/adapters/vercelBlob/staticHandler.js.map +0 -1
- package/dist/exports/azure.d.ts +0 -2
- package/dist/exports/azure.d.ts.map +0 -1
- package/dist/exports/azure.js +0 -3
- package/dist/exports/azure.js.map +0 -1
- package/dist/exports/gcs.d.ts +0 -2
- package/dist/exports/gcs.d.ts.map +0 -1
- package/dist/exports/gcs.js +0 -3
- package/dist/exports/gcs.js.map +0 -1
- package/dist/exports/s3.d.ts +0 -2
- package/dist/exports/s3.d.ts.map +0 -1
- package/dist/exports/s3.js +0 -3
- package/dist/exports/s3.js.map +0 -1
- package/dist/exports/vercelBlob.d.ts +0 -2
- package/dist/exports/vercelBlob.d.ts.map +0 -1
- package/dist/exports/vercelBlob.js +0 -3
- package/dist/exports/vercelBlob.js.map +0 -1
- package/dist/utilities/getRangeFromHeader.d.ts +0 -7
- package/dist/utilities/getRangeFromHeader.d.ts.map +0 -1
- package/dist/utilities/getRangeFromHeader.js +0 -22
- package/dist/utilities/getRangeFromHeader.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-cloud-storage",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"description": "The official cloud storage plugin for Payload CMS",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -33,26 +33,6 @@
|
|
|
33
33
|
"import": "./dist/exports/utilities.js",
|
|
34
34
|
"types": "./dist/exports/utilities.d.ts",
|
|
35
35
|
"default": "./dist/exports/utilities.js"
|
|
36
|
-
},
|
|
37
|
-
"./azure": {
|
|
38
|
-
"import": "./dist/exports/azure.js",
|
|
39
|
-
"types": "./dist/exports/azure.d.ts",
|
|
40
|
-
"default": "./dist/exports/azure.js"
|
|
41
|
-
},
|
|
42
|
-
"./gcs": {
|
|
43
|
-
"import": "./dist/exports/gcs.js",
|
|
44
|
-
"types": "./dist/exports/gcs.d.ts",
|
|
45
|
-
"default": "./dist/exports/gcs.js"
|
|
46
|
-
},
|
|
47
|
-
"./s3": {
|
|
48
|
-
"import": "./dist/exports/s3.js",
|
|
49
|
-
"types": "./dist/exports/s3.d.ts",
|
|
50
|
-
"default": "./dist/exports/s3.js"
|
|
51
|
-
},
|
|
52
|
-
"./vercelBlob": {
|
|
53
|
-
"import": "./dist/exports/vercelBlob.js",
|
|
54
|
-
"types": "./dist/exports/vercelBlob.d.ts",
|
|
55
|
-
"default": "./dist/exports/vercelBlob.js"
|
|
56
36
|
}
|
|
57
37
|
},
|
|
58
38
|
"main": "./dist/index.js",
|
|
@@ -67,42 +47,11 @@
|
|
|
67
47
|
"range-parser": "^1.2.1"
|
|
68
48
|
},
|
|
69
49
|
"devDependencies": {
|
|
70
|
-
"@aws-sdk/client-s3": "^3.614.0",
|
|
71
|
-
"@aws-sdk/lib-storage": "^3.614.0",
|
|
72
|
-
"@azure/storage-blob": "^12.11.0",
|
|
73
|
-
"@google-cloud/storage": "^7.7.0",
|
|
74
50
|
"@types/find-node-modules": "^2.1.2",
|
|
75
|
-
"
|
|
76
|
-
"payload": "3.12.1-canary.b1b1cbf"
|
|
51
|
+
"payload": "3.13.0"
|
|
77
52
|
},
|
|
78
53
|
"peerDependencies": {
|
|
79
|
-
"
|
|
80
|
-
"@aws-sdk/lib-storage": "^3.614.0",
|
|
81
|
-
"@azure/abort-controller": "^1.0.0",
|
|
82
|
-
"@azure/storage-blob": "^12.11.0",
|
|
83
|
-
"@google-cloud/storage": "^7.7.0",
|
|
84
|
-
"@vercel/blob": "^0.22.3",
|
|
85
|
-
"payload": "3.12.1-canary.b1b1cbf"
|
|
86
|
-
},
|
|
87
|
-
"peerDependenciesMeta": {
|
|
88
|
-
"@aws-sdk/client-s3": {
|
|
89
|
-
"optional": true
|
|
90
|
-
},
|
|
91
|
-
"@aws-sdk/lib-storage": {
|
|
92
|
-
"optional": true
|
|
93
|
-
},
|
|
94
|
-
"@azure/abort-controller": {
|
|
95
|
-
"optional": true
|
|
96
|
-
},
|
|
97
|
-
"@azure/storage-blob": {
|
|
98
|
-
"optional": true
|
|
99
|
-
},
|
|
100
|
-
"@google-cloud/storage": {
|
|
101
|
-
"optional": true
|
|
102
|
-
},
|
|
103
|
-
"@vercel/blob": {
|
|
104
|
-
"optional": true
|
|
105
|
-
}
|
|
54
|
+
"payload": "3.13.0"
|
|
106
55
|
},
|
|
107
56
|
"publishConfig": {
|
|
108
57
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generateURL.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/generateURL.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,UAAU,IAAI;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,eAAO,MAAM,cAAc,+BACI,IAAI,KAAG,WAGnC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/azure/generateURL.ts"],"sourcesContent":["import path from 'path'\n\nimport type { GenerateURL } from '../../types.js'\n\ninterface Args {\n baseURL: string\n containerName: string\n}\n\nexport const getGenerateURL =\n ({ baseURL, containerName }: Args): GenerateURL =>\n ({ filename, prefix = '' }) => {\n return `${baseURL}/${containerName}/${path.posix.join(prefix, filename)}`\n }\n"],"names":["path","getGenerateURL","baseURL","containerName","filename","prefix","posix","join"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,iBACX,CAAC,EAAEC,OAAO,EAAEC,aAAa,EAAQ,GACjC,CAAC,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAAE;QACxB,OAAO,GAAGH,QAAQ,CAAC,EAAEC,cAAc,CAAC,EAAEH,KAAKM,KAAK,CAACC,IAAI,CAACF,QAAQD,WAAW;IAC3E,EAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ContainerClient } from '@azure/storage-blob';
|
|
2
|
-
import type { CollectionConfig } from 'payload';
|
|
3
|
-
import type { HandleDelete } from '../../types.js';
|
|
4
|
-
interface Args {
|
|
5
|
-
collection: CollectionConfig;
|
|
6
|
-
getStorageClient: () => ContainerClient;
|
|
7
|
-
}
|
|
8
|
-
export declare const getHandleDelete: ({ getStorageClient }: Args) => HandleDelete;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=handleDelete.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handleDelete.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/handleDelete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,eAAe,CAAA;CACxC;AAED,eAAO,MAAM,eAAe,yBAA0B,IAAI,KAAG,YAK5D,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
export const getHandleDelete = ({ getStorageClient })=>{
|
|
3
|
-
return async ({ doc: { prefix = '' }, filename })=>{
|
|
4
|
-
const blockBlobClient = getStorageClient().getBlockBlobClient(path.posix.join(prefix, filename));
|
|
5
|
-
await blockBlobClient.deleteIfExists();
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=handleDelete.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/azure/handleDelete.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { CollectionConfig } from 'payload'\n\nimport path from 'path'\n\nimport type { HandleDelete } from '../../types.js'\n\ninterface Args {\n collection: CollectionConfig\n getStorageClient: () => ContainerClient\n}\n\nexport const getHandleDelete = ({ getStorageClient }: Args): HandleDelete => {\n return async ({ doc: { prefix = '' }, filename }) => {\n const blockBlobClient = getStorageClient().getBlockBlobClient(path.posix.join(prefix, filename))\n await blockBlobClient.deleteIfExists()\n }\n}\n"],"names":["path","getHandleDelete","getStorageClient","doc","prefix","filename","blockBlobClient","getBlockBlobClient","posix","join","deleteIfExists"],"mappings":"AAGA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,gBAAgB,EAAQ;IACxD,OAAO,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAE,EAAE,EAAEC,QAAQ,EAAE;QAC9C,MAAMC,kBAAkBJ,mBAAmBK,kBAAkB,CAACP,KAAKQ,KAAK,CAACC,IAAI,CAACL,QAAQC;QACtF,MAAMC,gBAAgBI,cAAc;IACtC;AACF,EAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ContainerClient } from '@azure/storage-blob';
|
|
2
|
-
import type { CollectionConfig } from 'payload';
|
|
3
|
-
import type { HandleUpload } from '../../types.js';
|
|
4
|
-
interface Args {
|
|
5
|
-
collection: CollectionConfig;
|
|
6
|
-
getStorageClient: () => ContainerClient;
|
|
7
|
-
prefix?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const getHandleUpload: ({ getStorageClient, prefix }: Args) => HandleUpload;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=handleUpload.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handleUpload.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/handleUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAO/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,eAAe,CAAA;IACvC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAGD,eAAO,MAAM,eAAe,iCAAuC,IAAI,KAAG,YAyBzE,CAAA"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { AbortController } from '@azure/abort-controller';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { Readable } from 'stream';
|
|
5
|
-
const multipartThreshold = 1024 * 1024 * 50 // 50MB
|
|
6
|
-
;
|
|
7
|
-
export const getHandleUpload = ({ getStorageClient, prefix = '' })=>{
|
|
8
|
-
return async ({ data, file })=>{
|
|
9
|
-
const fileKey = path.posix.join(data.prefix || prefix, file.filename);
|
|
10
|
-
const blockBlobClient = getStorageClient().getBlockBlobClient(fileKey);
|
|
11
|
-
// when there are no temp files, or the upload is less than the threshold size, do not stream files
|
|
12
|
-
if (!file.tempFilePath && file.buffer.length > 0 && file.buffer.length < multipartThreshold) {
|
|
13
|
-
await blockBlobClient.upload(file.buffer, file.buffer.byteLength, {
|
|
14
|
-
blobHTTPHeaders: {
|
|
15
|
-
blobContentType: file.mimeType
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
return data;
|
|
19
|
-
}
|
|
20
|
-
const fileBufferOrStream = file.tempFilePath ? fs.createReadStream(file.tempFilePath) : Readable.from(file.buffer);
|
|
21
|
-
await blockBlobClient.uploadStream(fileBufferOrStream, 4 * 1024 * 1024, 4, {
|
|
22
|
-
abortSignal: AbortController.timeout(30 * 60 * 1000)
|
|
23
|
-
});
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=handleUpload.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/azure/handleUpload.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { CollectionConfig } from 'payload'\n\nimport { AbortController } from '@azure/abort-controller'\nimport fs from 'fs'\nimport path from 'path'\nimport { Readable } from 'stream'\n\nimport type { HandleUpload } from '../../types.js'\n\ninterface Args {\n collection: CollectionConfig\n getStorageClient: () => ContainerClient\n prefix?: string\n}\n\nconst multipartThreshold = 1024 * 1024 * 50 // 50MB\nexport const getHandleUpload = ({ getStorageClient, prefix = '' }: Args): HandleUpload => {\n return async ({ data, file }) => {\n const fileKey = path.posix.join(data.prefix || prefix, file.filename)\n\n const blockBlobClient = getStorageClient().getBlockBlobClient(fileKey)\n\n // when there are no temp files, or the upload is less than the threshold size, do not stream files\n if (!file.tempFilePath && file.buffer.length > 0 && file.buffer.length < multipartThreshold) {\n await blockBlobClient.upload(file.buffer, file.buffer.byteLength, {\n blobHTTPHeaders: { blobContentType: file.mimeType },\n })\n\n return data\n }\n\n const fileBufferOrStream: Readable = file.tempFilePath\n ? fs.createReadStream(file.tempFilePath)\n : Readable.from(file.buffer)\n\n await blockBlobClient.uploadStream(fileBufferOrStream, 4 * 1024 * 1024, 4, {\n abortSignal: AbortController.timeout(30 * 60 * 1000),\n })\n\n return data\n }\n}\n"],"names":["AbortController","fs","path","Readable","multipartThreshold","getHandleUpload","getStorageClient","prefix","data","file","fileKey","posix","join","filename","blockBlobClient","getBlockBlobClient","tempFilePath","buffer","length","upload","byteLength","blobHTTPHeaders","blobContentType","mimeType","fileBufferOrStream","createReadStream","from","uploadStream","abortSignal","timeout"],"mappings":"AAGA,SAASA,eAAe,QAAQ,0BAAyB;AACzD,OAAOC,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,QAAQ,QAAQ,SAAQ;AAUjC,MAAMC,qBAAqB,OAAO,OAAO,GAAG,OAAO;;AACnD,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,gBAAgB,EAAEC,SAAS,EAAE,EAAQ;IACrE,OAAO,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAE;QAC1B,MAAMC,UAAUR,KAAKS,KAAK,CAACC,IAAI,CAACJ,KAAKD,MAAM,IAAIA,QAAQE,KAAKI,QAAQ;QAEpE,MAAMC,kBAAkBR,mBAAmBS,kBAAkB,CAACL;QAE9D,mGAAmG;QACnG,IAAI,CAACD,KAAKO,YAAY,IAAIP,KAAKQ,MAAM,CAACC,MAAM,GAAG,KAAKT,KAAKQ,MAAM,CAACC,MAAM,GAAGd,oBAAoB;YAC3F,MAAMU,gBAAgBK,MAAM,CAACV,KAAKQ,MAAM,EAAER,KAAKQ,MAAM,CAACG,UAAU,EAAE;gBAChEC,iBAAiB;oBAAEC,iBAAiBb,KAAKc,QAAQ;gBAAC;YACpD;YAEA,OAAOf;QACT;QAEA,MAAMgB,qBAA+Bf,KAAKO,YAAY,GAClDf,GAAGwB,gBAAgB,CAAChB,KAAKO,YAAY,IACrCb,SAASuB,IAAI,CAACjB,KAAKQ,MAAM;QAE7B,MAAMH,gBAAgBa,YAAY,CAACH,oBAAoB,IAAI,OAAO,MAAM,GAAG;YACzEI,aAAa5B,gBAAgB6B,OAAO,CAAC,KAAK,KAAK;QACjD;QAEA,OAAOrB;IACT;AACF,EAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Adapter } from '../../types.js';
|
|
2
|
-
export interface Args {
|
|
3
|
-
allowContainerCreate: boolean;
|
|
4
|
-
baseURL: string;
|
|
5
|
-
connectionString: string;
|
|
6
|
-
containerName: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated Use [`@payloadcms/azure`](https://www.npmjs.com/package/@payloadcms/azure) instead.
|
|
10
|
-
*
|
|
11
|
-
* This adapter has been superceded by `@payloadcms/azure` and will be removed in Payload 3.0.
|
|
12
|
-
*/
|
|
13
|
-
export declare const azureBlobStorageAdapter: ({ allowContainerCreate, baseURL, connectionString, containerName, }: Args) => Adapter;
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,wEAKjC,IAAI,KAAG,OA6CT,CAAA"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { BlobServiceClient } from '@azure/storage-blob';
|
|
2
|
-
import { getGenerateURL } from './generateURL.js';
|
|
3
|
-
import { getHandleDelete } from './handleDelete.js';
|
|
4
|
-
import { getHandleUpload } from './handleUpload.js';
|
|
5
|
-
import { getHandler } from './staticHandler.js';
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use [`@payloadcms/azure`](https://www.npmjs.com/package/@payloadcms/azure) instead.
|
|
8
|
-
*
|
|
9
|
-
* This adapter has been superceded by `@payloadcms/azure` and will be removed in Payload 3.0.
|
|
10
|
-
*/ export const azureBlobStorageAdapter = ({ allowContainerCreate, baseURL, connectionString, containerName })=>{
|
|
11
|
-
if (!BlobServiceClient) {
|
|
12
|
-
throw new Error('The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.');
|
|
13
|
-
}
|
|
14
|
-
let storageClient = null;
|
|
15
|
-
const getStorageClient = ()=>{
|
|
16
|
-
if (storageClient) {
|
|
17
|
-
return storageClient;
|
|
18
|
-
}
|
|
19
|
-
let blobServiceClient = null;
|
|
20
|
-
try {
|
|
21
|
-
blobServiceClient = BlobServiceClient.fromConnectionString(connectionString);
|
|
22
|
-
} catch (error) {
|
|
23
|
-
if (/is not a constructor$/.test(error.message)) {
|
|
24
|
-
throw new Error('The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.');
|
|
25
|
-
}
|
|
26
|
-
// Re-throw other unexpected errors.
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
return storageClient = blobServiceClient.getContainerClient(containerName);
|
|
30
|
-
};
|
|
31
|
-
const createContainerIfNotExists = ()=>{
|
|
32
|
-
getStorageClient().createIfNotExists({
|
|
33
|
-
access: 'blob'
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
return ({ collection, prefix })=>{
|
|
37
|
-
return {
|
|
38
|
-
name: 'azure',
|
|
39
|
-
generateURL: getGenerateURL({
|
|
40
|
-
baseURL,
|
|
41
|
-
containerName
|
|
42
|
-
}),
|
|
43
|
-
handleDelete: getHandleDelete({
|
|
44
|
-
collection,
|
|
45
|
-
getStorageClient
|
|
46
|
-
}),
|
|
47
|
-
handleUpload: getHandleUpload({
|
|
48
|
-
collection,
|
|
49
|
-
getStorageClient,
|
|
50
|
-
prefix
|
|
51
|
-
}),
|
|
52
|
-
staticHandler: getHandler({
|
|
53
|
-
collection,
|
|
54
|
-
getStorageClient
|
|
55
|
-
}),
|
|
56
|
-
...allowContainerCreate && {
|
|
57
|
-
onInit: createContainerIfNotExists
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/azure/index.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\n\nimport { BlobServiceClient } from '@azure/storage-blob'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n allowContainerCreate: boolean\n baseURL: string\n connectionString: string\n containerName: string\n}\n\n/**\n * @deprecated Use [`@payloadcms/azure`](https://www.npmjs.com/package/@payloadcms/azure) instead.\n *\n * This adapter has been superceded by `@payloadcms/azure` and will be removed in Payload 3.0.\n */\nexport const azureBlobStorageAdapter = ({\n allowContainerCreate,\n baseURL,\n connectionString,\n containerName,\n}: Args): Adapter => {\n if (!BlobServiceClient) {\n throw new Error(\n 'The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.',\n )\n }\n\n let storageClient: ContainerClient | null = null\n const getStorageClient = () => {\n if (storageClient) {\n return storageClient\n }\n let blobServiceClient = null\n try {\n blobServiceClient = BlobServiceClient.fromConnectionString(connectionString)\n } catch (error) {\n if (/is not a constructor$/.test(error.message)) {\n throw new Error(\n 'The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.',\n )\n }\n // Re-throw other unexpected errors.\n throw error\n }\n return (storageClient = blobServiceClient.getContainerClient(containerName))\n }\n\n const createContainerIfNotExists = () => {\n getStorageClient().createIfNotExists({ access: 'blob' })\n }\n\n return ({ collection, prefix }): GeneratedAdapter => {\n return {\n name: 'azure',\n generateURL: getGenerateURL({ baseURL, containerName }),\n handleDelete: getHandleDelete({ collection, getStorageClient }),\n handleUpload: getHandleUpload({\n collection,\n getStorageClient,\n prefix,\n }),\n staticHandler: getHandler({ collection, getStorageClient }),\n ...(allowContainerCreate && { onInit: createContainerIfNotExists }),\n }\n }\n}\n"],"names":["BlobServiceClient","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","azureBlobStorageAdapter","allowContainerCreate","baseURL","connectionString","containerName","Error","storageClient","getStorageClient","blobServiceClient","fromConnectionString","error","test","message","getContainerClient","createContainerIfNotExists","createIfNotExists","access","collection","prefix","name","generateURL","handleDelete","handleUpload","staticHandler","onInit"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,sBAAqB;AAIvD,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAS/C;;;;CAIC,GACD,OAAO,MAAMC,0BAA0B,CAAC,EACtCC,oBAAoB,EACpBC,OAAO,EACPC,gBAAgB,EAChBC,aAAa,EACR;IACL,IAAI,CAACT,mBAAmB;QACtB,MAAM,IAAIU,MACR;IAEJ;IAEA,IAAIC,gBAAwC;IAC5C,MAAMC,mBAAmB;QACvB,IAAID,eAAe;YACjB,OAAOA;QACT;QACA,IAAIE,oBAAoB;QACxB,IAAI;YACFA,oBAAoBb,kBAAkBc,oBAAoB,CAACN;QAC7D,EAAE,OAAOO,OAAO;YACd,IAAI,wBAAwBC,IAAI,CAACD,MAAME,OAAO,GAAG;gBAC/C,MAAM,IAAIP,MACR;YAEJ;YACA,oCAAoC;YACpC,MAAMK;QACR;QACA,OAAQJ,gBAAgBE,kBAAkBK,kBAAkB,CAACT;IAC/D;IAEA,MAAMU,6BAA6B;QACjCP,mBAAmBQ,iBAAiB,CAAC;YAAEC,QAAQ;QAAO;IACxD;IAEA,OAAO,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QAC5B,OAAO;YACLC,MAAM;YACNC,aAAaxB,eAAe;gBAAEM;gBAASE;YAAc;YACrDiB,cAAcxB,gBAAgB;gBAAEoB;gBAAYV;YAAiB;YAC7De,cAAcxB,gBAAgB;gBAC5BmB;gBACAV;gBACAW;YACF;YACAK,eAAexB,WAAW;gBAAEkB;gBAAYV;YAAiB;YACzD,GAAIN,wBAAwB;gBAAEuB,QAAQV;YAA2B,CAAC;QACpE;IACF;AACF,EAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ContainerClient } from '@azure/storage-blob';
|
|
2
|
-
import type { CollectionConfig } from 'payload';
|
|
3
|
-
import type { StaticHandler } from '../../types.js';
|
|
4
|
-
interface Args {
|
|
5
|
-
collection: CollectionConfig;
|
|
6
|
-
getStorageClient: () => ContainerClient;
|
|
7
|
-
}
|
|
8
|
-
export declare const getHandler: ({ collection, getStorageClient }: Args) => StaticHandler;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=staticHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"staticHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/staticHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAKnD,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,eAAe,CAAA;CACxC;AAED,eAAO,MAAM,UAAU,qCAAsC,IAAI,KAAG,aAuCnE,CAAA"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { getFilePrefix } from '../../utilities/getFilePrefix.js';
|
|
3
|
-
import getRangeFromHeader from '../../utilities/getRangeFromHeader.js';
|
|
4
|
-
export const getHandler = ({ collection, getStorageClient })=>{
|
|
5
|
-
return async (req, { params: { filename } })=>{
|
|
6
|
-
try {
|
|
7
|
-
const prefix = await getFilePrefix({
|
|
8
|
-
collection,
|
|
9
|
-
filename,
|
|
10
|
-
req
|
|
11
|
-
});
|
|
12
|
-
const blockBlobClient = getStorageClient().getBlockBlobClient(path.posix.join(prefix, filename));
|
|
13
|
-
const { end, start } = await getRangeFromHeader(blockBlobClient, req.headers.get('range'));
|
|
14
|
-
const blob = await blockBlobClient.download(start, end);
|
|
15
|
-
const response = blob._response;
|
|
16
|
-
// Manually create a ReadableStream for the web from a Node.js stream.
|
|
17
|
-
const readableStream = new ReadableStream({
|
|
18
|
-
start (controller) {
|
|
19
|
-
const nodeStream = blob.readableStreamBody;
|
|
20
|
-
nodeStream.on('data', (chunk)=>{
|
|
21
|
-
controller.enqueue(new Uint8Array(chunk));
|
|
22
|
-
});
|
|
23
|
-
nodeStream.on('end', ()=>{
|
|
24
|
-
controller.close();
|
|
25
|
-
});
|
|
26
|
-
nodeStream.on('error', (err)=>{
|
|
27
|
-
controller.error(err);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return new Response(readableStream, {
|
|
32
|
-
headers: response.headers.rawHeaders(),
|
|
33
|
-
status: response.status
|
|
34
|
-
});
|
|
35
|
-
} catch (err) {
|
|
36
|
-
req.payload.logger.error(err);
|
|
37
|
-
return new Response('Internal Server Error', {
|
|
38
|
-
status: 500
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=staticHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/azure/staticHandler.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { CollectionConfig } from 'payload'\n\nimport path from 'path'\n\nimport type { StaticHandler } from '../../types.js'\n\nimport { getFilePrefix } from '../../utilities/getFilePrefix.js'\nimport getRangeFromHeader from '../../utilities/getRangeFromHeader.js'\n\ninterface Args {\n collection: CollectionConfig\n getStorageClient: () => ContainerClient\n}\n\nexport const getHandler = ({ collection, getStorageClient }: Args): StaticHandler => {\n return async (req, { params: { filename } }) => {\n try {\n const prefix = await getFilePrefix({ collection, filename, req })\n const blockBlobClient = getStorageClient().getBlockBlobClient(\n path.posix.join(prefix, filename),\n )\n\n const { end, start } = await getRangeFromHeader(blockBlobClient, req.headers.get('range'))\n\n const blob = await blockBlobClient.download(start, end)\n\n const response = blob._response\n\n // Manually create a ReadableStream for the web from a Node.js stream.\n const readableStream = new ReadableStream({\n start(controller) {\n const nodeStream = blob.readableStreamBody\n nodeStream.on('data', (chunk) => {\n controller.enqueue(new Uint8Array(chunk))\n })\n nodeStream.on('end', () => {\n controller.close()\n })\n nodeStream.on('error', (err) => {\n controller.error(err)\n })\n },\n })\n\n return new Response(readableStream, {\n headers: response.headers.rawHeaders(),\n status: response.status,\n })\n } catch (err: unknown) {\n req.payload.logger.error(err)\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["path","getFilePrefix","getRangeFromHeader","getHandler","collection","getStorageClient","req","params","filename","prefix","blockBlobClient","getBlockBlobClient","posix","join","end","start","headers","get","blob","download","response","_response","readableStream","ReadableStream","controller","nodeStream","readableStreamBody","on","chunk","enqueue","Uint8Array","close","err","error","Response","rawHeaders","status","payload","logger"],"mappings":"AAGA,OAAOA,UAAU,OAAM;AAIvB,SAASC,aAAa,QAAQ,mCAAkC;AAChE,OAAOC,wBAAwB,wCAAuC;AAOtE,OAAO,MAAMC,aAAa,CAAC,EAAEC,UAAU,EAAEC,gBAAgB,EAAQ;IAC/D,OAAO,OAAOC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,EAAE;QACzC,IAAI;YACF,MAAMC,SAAS,MAAMR,cAAc;gBAAEG;gBAAYI;gBAAUF;YAAI;YAC/D,MAAMI,kBAAkBL,mBAAmBM,kBAAkB,CAC3DX,KAAKY,KAAK,CAACC,IAAI,CAACJ,QAAQD;YAG1B,MAAM,EAAEM,GAAG,EAAEC,KAAK,EAAE,GAAG,MAAMb,mBAAmBQ,iBAAiBJ,IAAIU,OAAO,CAACC,GAAG,CAAC;YAEjF,MAAMC,OAAO,MAAMR,gBAAgBS,QAAQ,CAACJ,OAAOD;YAEnD,MAAMM,WAAWF,KAAKG,SAAS;YAE/B,sEAAsE;YACtE,MAAMC,iBAAiB,IAAIC,eAAe;gBACxCR,OAAMS,UAAU;oBACd,MAAMC,aAAaP,KAAKQ,kBAAkB;oBAC1CD,WAAWE,EAAE,CAAC,QAAQ,CAACC;wBACrBJ,WAAWK,OAAO,CAAC,IAAIC,WAAWF;oBACpC;oBACAH,WAAWE,EAAE,CAAC,OAAO;wBACnBH,WAAWO,KAAK;oBAClB;oBACAN,WAAWE,EAAE,CAAC,SAAS,CAACK;wBACtBR,WAAWS,KAAK,CAACD;oBACnB;gBACF;YACF;YAEA,OAAO,IAAIE,SAASZ,gBAAgB;gBAClCN,SAASI,SAASJ,OAAO,CAACmB,UAAU;gBACpCC,QAAQhB,SAASgB,MAAM;YACzB;QACF,EAAE,OAAOJ,KAAc;YACrB1B,IAAI+B,OAAO,CAACC,MAAM,CAACL,KAAK,CAACD;YACzB,OAAO,IAAIE,SAAS,yBAAyB;gBAAEE,QAAQ;YAAI;QAC7D;IACF;AACF,EAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Storage } from '@google-cloud/storage';
|
|
2
|
-
import type { GenerateURL } from '../../types.js';
|
|
3
|
-
interface Args {
|
|
4
|
-
bucket: string;
|
|
5
|
-
getStorageClient: () => Storage;
|
|
6
|
-
}
|
|
7
|
-
export declare const getGenerateURL: ({ bucket, getStorageClient }: Args) => GenerateURL;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=generateURL.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generateURL.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/generateURL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAIpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,UAAU,IAAI;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,MAAM,OAAO,CAAA;CAChC;AAED,eAAO,MAAM,cAAc,iCACM,IAAI,KAAG,WAKrC,CAAA"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
export const getGenerateURL = ({ bucket, getStorageClient })=>({ filename, prefix = '' })=>{
|
|
3
|
-
return decodeURIComponent(getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename)).publicUrl());
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=generateURL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/gcs/generateURL.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\n\nimport path from 'path'\n\nimport type { GenerateURL } from '../../types.js'\n\ninterface Args {\n bucket: string\n getStorageClient: () => Storage\n}\n\nexport const getGenerateURL =\n ({ bucket, getStorageClient }: Args): GenerateURL =>\n ({ filename, prefix = '' }) => {\n return decodeURIComponent(\n getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename)).publicUrl(),\n )\n }\n"],"names":["path","getGenerateURL","bucket","getStorageClient","filename","prefix","decodeURIComponent","file","posix","join","publicUrl"],"mappings":"AAEA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,iBACX,CAAC,EAAEC,MAAM,EAAEC,gBAAgB,EAAQ,GACnC,CAAC,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAAE;QACxB,OAAOC,mBACLH,mBAAmBD,MAAM,CAACA,QAAQK,IAAI,CAACP,KAAKQ,KAAK,CAACC,IAAI,CAACJ,QAAQD,WAAWM,SAAS;IAEvF,EAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Storage } from '@google-cloud/storage';
|
|
2
|
-
import type { HandleDelete } from '../../types.js';
|
|
3
|
-
interface Args {
|
|
4
|
-
bucket: string;
|
|
5
|
-
getStorageClient: () => Storage;
|
|
6
|
-
}
|
|
7
|
-
export declare const getHandleDelete: ({ bucket, getStorageClient }: Args) => HandleDelete;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=handleDelete.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handleDelete.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/handleDelete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAIpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,MAAM,OAAO,CAAA;CAChC;AAED,eAAO,MAAM,eAAe,iCAAkC,IAAI,KAAG,YAMpE,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
export const getHandleDelete = ({ bucket, getStorageClient })=>{
|
|
3
|
-
return async ({ doc: { prefix = '' }, filename })=>{
|
|
4
|
-
await getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename)).delete({
|
|
5
|
-
ignoreNotFound: true
|
|
6
|
-
});
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=handleDelete.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/gcs/handleDelete.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\n\nimport path from 'path'\n\nimport type { HandleDelete } from '../../types.js'\n\ninterface Args {\n bucket: string\n getStorageClient: () => Storage\n}\n\nexport const getHandleDelete = ({ bucket, getStorageClient }: Args): HandleDelete => {\n return async ({ doc: { prefix = '' }, filename }) => {\n await getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename)).delete({\n ignoreNotFound: true,\n })\n }\n}\n"],"names":["path","getHandleDelete","bucket","getStorageClient","doc","prefix","filename","file","posix","join","delete","ignoreNotFound"],"mappings":"AAEA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,MAAM,EAAEC,gBAAgB,EAAQ;IAChE,OAAO,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAE,EAAE,EAAEC,QAAQ,EAAE;QAC9C,MAAMH,mBAAmBD,MAAM,CAACA,QAAQK,IAAI,CAACP,KAAKQ,KAAK,CAACC,IAAI,CAACJ,QAAQC,WAAWI,MAAM,CAAC;YACrFC,gBAAgB;QAClB;IACF;AACF,EAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Storage } from '@google-cloud/storage';
|
|
2
|
-
import type { CollectionConfig } from 'payload';
|
|
3
|
-
import type { HandleUpload } from '../../types.js';
|
|
4
|
-
interface Args {
|
|
5
|
-
acl?: 'Private' | 'Public';
|
|
6
|
-
bucket: string;
|
|
7
|
-
collection: CollectionConfig;
|
|
8
|
-
getStorageClient: () => Storage;
|
|
9
|
-
prefix?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const getHandleUpload: ({ acl, bucket, getStorageClient, prefix, }: Args) => HandleUpload;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=handleUpload.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handleUpload.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/handleUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,OAAO,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,eAAe,+CAKzB,IAAI,KAAG,YAiBT,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
export const getHandleUpload = ({ acl, bucket, getStorageClient, prefix = '' })=>{
|
|
3
|
-
return async ({ data, file })=>{
|
|
4
|
-
const fileKey = path.posix.join(data.prefix || prefix, file.filename);
|
|
5
|
-
const gcsFile = getStorageClient().bucket(bucket).file(fileKey);
|
|
6
|
-
await gcsFile.save(file.buffer, {
|
|
7
|
-
metadata: {
|
|
8
|
-
contentType: file.mimeType
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
if (acl) {
|
|
12
|
-
await gcsFile[`make${acl}`]();
|
|
13
|
-
}
|
|
14
|
-
return data;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=handleUpload.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/gcs/handleUpload.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\nimport type { CollectionConfig } from 'payload'\n\nimport path from 'path'\n\nimport type { HandleUpload } from '../../types.js'\n\ninterface Args {\n acl?: 'Private' | 'Public'\n bucket: string\n collection: CollectionConfig\n getStorageClient: () => Storage\n prefix?: string\n}\n\nexport const getHandleUpload = ({\n acl,\n bucket,\n getStorageClient,\n prefix = '',\n}: Args): HandleUpload => {\n return async ({ data, file }) => {\n const fileKey = path.posix.join(data.prefix || prefix, file.filename)\n\n const gcsFile = getStorageClient().bucket(bucket).file(fileKey)\n await gcsFile.save(file.buffer, {\n metadata: {\n contentType: file.mimeType,\n },\n })\n\n if (acl) {\n await gcsFile[`make${acl}`]()\n }\n\n return data\n }\n}\n"],"names":["path","getHandleUpload","acl","bucket","getStorageClient","prefix","data","file","fileKey","posix","join","filename","gcsFile","save","buffer","metadata","contentType","mimeType"],"mappings":"AAGA,OAAOA,UAAU,OAAM;AAYvB,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,GAAG,EACHC,MAAM,EACNC,gBAAgB,EAChBC,SAAS,EAAE,EACN;IACL,OAAO,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAE;QAC1B,MAAMC,UAAUR,KAAKS,KAAK,CAACC,IAAI,CAACJ,KAAKD,MAAM,IAAIA,QAAQE,KAAKI,QAAQ;QAEpE,MAAMC,UAAUR,mBAAmBD,MAAM,CAACA,QAAQI,IAAI,CAACC;QACvD,MAAMI,QAAQC,IAAI,CAACN,KAAKO,MAAM,EAAE;YAC9BC,UAAU;gBACRC,aAAaT,KAAKU,QAAQ;YAC5B;QACF;QAEA,IAAIf,KAAK;YACP,MAAMU,OAAO,CAAC,CAAC,IAAI,EAAEV,KAAK,CAAC;QAC7B;QAEA,OAAOI;IACT;AACF,EAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { StorageOptions } from '@google-cloud/storage';
|
|
2
|
-
import type { Adapter } from '../../types.js';
|
|
3
|
-
export interface Args {
|
|
4
|
-
acl?: 'Private' | 'Public';
|
|
5
|
-
bucket: string;
|
|
6
|
-
options: StorageOptions;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated Use [`@payloadcms/storage-gcs`](https://www.npmjs.com/package/@payloadcms/storage-gcs) instead.
|
|
10
|
-
*
|
|
11
|
-
* This adapter has been superceded by `@payloadcms/storage-gcs` and will be removed in Payload 3.0.
|
|
12
|
-
*/
|
|
13
|
-
export declare const gcsAdapter: ({ acl, bucket, options }: Args) => Adapter;
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,cAAc,CAAA;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,6BACM,IAAI,KAAG,OAyCjC,CAAA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Storage } from '@google-cloud/storage';
|
|
2
|
-
import { getGenerateURL } from './generateURL.js';
|
|
3
|
-
import { getHandleDelete } from './handleDelete.js';
|
|
4
|
-
import { getHandleUpload } from './handleUpload.js';
|
|
5
|
-
import { getHandler } from './staticHandler.js';
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use [`@payloadcms/storage-gcs`](https://www.npmjs.com/package/@payloadcms/storage-gcs) instead.
|
|
8
|
-
*
|
|
9
|
-
* This adapter has been superceded by `@payloadcms/storage-gcs` and will be removed in Payload 3.0.
|
|
10
|
-
*/ export const gcsAdapter = ({ acl, bucket, options })=>({ collection, prefix })=>{
|
|
11
|
-
if (!Storage) {
|
|
12
|
-
throw new Error('The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.');
|
|
13
|
-
}
|
|
14
|
-
let storageClient = null;
|
|
15
|
-
const getStorageClient = ()=>{
|
|
16
|
-
if (storageClient) {
|
|
17
|
-
return storageClient;
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
storageClient = new Storage(options);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
if (/is not a constructor$/.test(error.message)) {
|
|
23
|
-
throw new Error('The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.');
|
|
24
|
-
}
|
|
25
|
-
// Re-throw other unexpected errors.
|
|
26
|
-
throw error;
|
|
27
|
-
}
|
|
28
|
-
return storageClient;
|
|
29
|
-
};
|
|
30
|
-
return {
|
|
31
|
-
name: 'gcs',
|
|
32
|
-
generateURL: getGenerateURL({
|
|
33
|
-
bucket,
|
|
34
|
-
getStorageClient
|
|
35
|
-
}),
|
|
36
|
-
handleDelete: getHandleDelete({
|
|
37
|
-
bucket,
|
|
38
|
-
getStorageClient
|
|
39
|
-
}),
|
|
40
|
-
handleUpload: getHandleUpload({
|
|
41
|
-
acl,
|
|
42
|
-
bucket,
|
|
43
|
-
collection,
|
|
44
|
-
getStorageClient,
|
|
45
|
-
prefix
|
|
46
|
-
}),
|
|
47
|
-
staticHandler: getHandler({
|
|
48
|
-
bucket,
|
|
49
|
-
collection,
|
|
50
|
-
getStorageClient
|
|
51
|
-
})
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/gcs/index.ts"],"sourcesContent":["import type { StorageOptions } from '@google-cloud/storage'\n\nimport { Storage } from '@google-cloud/storage'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n acl?: 'Private' | 'Public'\n bucket: string\n options: StorageOptions\n}\n\n/**\n * @deprecated Use [`@payloadcms/storage-gcs`](https://www.npmjs.com/package/@payloadcms/storage-gcs) instead.\n *\n * This adapter has been superceded by `@payloadcms/storage-gcs` and will be removed in Payload 3.0.\n */\nexport const gcsAdapter =\n ({ acl, bucket, options }: Args): Adapter =>\n ({ collection, prefix }): GeneratedAdapter => {\n if (!Storage) {\n throw new Error(\n 'The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.',\n )\n }\n\n let storageClient: null | Storage = null\n\n const getStorageClient = (): Storage => {\n if (storageClient) {\n return storageClient\n }\n try {\n storageClient = new Storage(options)\n } catch (error) {\n if (/is not a constructor$/.test(error.message)) {\n throw new Error(\n 'The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.',\n )\n }\n // Re-throw other unexpected errors.\n throw error\n }\n return storageClient\n }\n\n return {\n name: 'gcs',\n generateURL: getGenerateURL({ bucket, getStorageClient }),\n handleDelete: getHandleDelete({ bucket, getStorageClient }),\n handleUpload: getHandleUpload({\n acl,\n bucket,\n collection,\n getStorageClient,\n prefix,\n }),\n staticHandler: getHandler({ bucket, collection, getStorageClient }),\n }\n }\n"],"names":["Storage","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","gcsAdapter","acl","bucket","options","collection","prefix","Error","storageClient","getStorageClient","error","test","message","name","generateURL","handleDelete","handleUpload","staticHandler"],"mappings":"AAEA,SAASA,OAAO,QAAQ,wBAAuB;AAI/C,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAQ/C;;;;CAIC,GACD,OAAO,MAAMC,aACX,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAQ,GAC/B,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QACrB,IAAI,CAACV,SAAS;YACZ,MAAM,IAAIW,MACR;QAEJ;QAEA,IAAIC,gBAAgC;QAEpC,MAAMC,mBAAmB;YACvB,IAAID,eAAe;gBACjB,OAAOA;YACT;YACA,IAAI;gBACFA,gBAAgB,IAAIZ,QAAQQ;YAC9B,EAAE,OAAOM,OAAO;gBACd,IAAI,wBAAwBC,IAAI,CAACD,MAAME,OAAO,GAAG;oBAC/C,MAAM,IAAIL,MACR;gBAEJ;gBACA,oCAAoC;gBACpC,MAAMG;YACR;YACA,OAAOF;QACT;QAEA,OAAO;YACLK,MAAM;YACNC,aAAajB,eAAe;gBAAEM;gBAAQM;YAAiB;YACvDM,cAAcjB,gBAAgB;gBAAEK;gBAAQM;YAAiB;YACzDO,cAAcjB,gBAAgB;gBAC5BG;gBACAC;gBACAE;gBACAI;gBACAH;YACF;YACAW,eAAejB,WAAW;gBAAEG;gBAAQE;gBAAYI;YAAiB;QACnE;IACF,EAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Storage } from '@google-cloud/storage';
|
|
2
|
-
import type { CollectionConfig } from 'payload';
|
|
3
|
-
import type { StaticHandler } from '../../types.js';
|
|
4
|
-
interface Args {
|
|
5
|
-
bucket: string;
|
|
6
|
-
collection: CollectionConfig;
|
|
7
|
-
getStorageClient: () => Storage;
|
|
8
|
-
}
|
|
9
|
-
export declare const getHandler: ({ bucket, collection, getStorageClient }: Args) => StaticHandler;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=staticHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"staticHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/staticHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAInD,UAAU,IAAI;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,OAAO,CAAA;CAChC;AAED,eAAO,MAAM,UAAU,6CAA8C,IAAI,KAAG,aAqC3E,CAAA"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { getFilePrefix } from '../../utilities/getFilePrefix.js';
|
|
3
|
-
export const getHandler = ({ bucket, collection, getStorageClient })=>{
|
|
4
|
-
return async (req, { params: { filename } })=>{
|
|
5
|
-
try {
|
|
6
|
-
const prefix = await getFilePrefix({
|
|
7
|
-
collection,
|
|
8
|
-
filename,
|
|
9
|
-
req
|
|
10
|
-
});
|
|
11
|
-
const file = getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename));
|
|
12
|
-
const [metadata] = await file.getMetadata();
|
|
13
|
-
// Manually create a ReadableStream for the web from a Node.js stream.
|
|
14
|
-
const readableStream = new ReadableStream({
|
|
15
|
-
start (controller) {
|
|
16
|
-
const nodeStream = file.createReadStream();
|
|
17
|
-
nodeStream.on('data', (chunk)=>{
|
|
18
|
-
controller.enqueue(new Uint8Array(chunk));
|
|
19
|
-
});
|
|
20
|
-
nodeStream.on('end', ()=>{
|
|
21
|
-
controller.close();
|
|
22
|
-
});
|
|
23
|
-
nodeStream.on('error', (err)=>{
|
|
24
|
-
controller.error(err);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return new Response(readableStream, {
|
|
29
|
-
headers: new Headers({
|
|
30
|
-
'Content-Length': String(metadata.size),
|
|
31
|
-
'Content-Type': metadata.contentType,
|
|
32
|
-
ETag: metadata.etag
|
|
33
|
-
}),
|
|
34
|
-
status: 200
|
|
35
|
-
});
|
|
36
|
-
} catch (err) {
|
|
37
|
-
req.payload.logger.error(err);
|
|
38
|
-
return new Response('Internal Server Error', {
|
|
39
|
-
status: 500
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=staticHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/gcs/staticHandler.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\nimport type { CollectionConfig } from 'payload'\n\nimport path from 'path'\n\nimport type { StaticHandler } from '../../types.js'\n\nimport { getFilePrefix } from '../../utilities/getFilePrefix.js'\n\ninterface Args {\n bucket: string\n collection: CollectionConfig\n getStorageClient: () => Storage\n}\n\nexport const getHandler = ({ bucket, collection, getStorageClient }: Args): StaticHandler => {\n return async (req, { params: { filename } }) => {\n try {\n const prefix = await getFilePrefix({ collection, filename, req })\n const file = getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename))\n\n const [metadata] = await file.getMetadata()\n\n // Manually create a ReadableStream for the web from a Node.js stream.\n const readableStream = new ReadableStream({\n start(controller) {\n const nodeStream = file.createReadStream()\n nodeStream.on('data', (chunk) => {\n controller.enqueue(new Uint8Array(chunk))\n })\n nodeStream.on('end', () => {\n controller.close()\n })\n nodeStream.on('error', (err) => {\n controller.error(err)\n })\n },\n })\n\n return new Response(readableStream, {\n headers: new Headers({\n 'Content-Length': String(metadata.size),\n 'Content-Type': metadata.contentType,\n ETag: metadata.etag,\n }),\n status: 200,\n })\n } catch (err: unknown) {\n req.payload.logger.error(err)\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["path","getFilePrefix","getHandler","bucket","collection","getStorageClient","req","params","filename","prefix","file","posix","join","metadata","getMetadata","readableStream","ReadableStream","start","controller","nodeStream","createReadStream","on","chunk","enqueue","Uint8Array","close","err","error","Response","headers","Headers","String","size","contentType","ETag","etag","status","payload","logger"],"mappings":"AAGA,OAAOA,UAAU,OAAM;AAIvB,SAASC,aAAa,QAAQ,mCAAkC;AAQhE,OAAO,MAAMC,aAAa,CAAC,EAAEC,MAAM,EAAEC,UAAU,EAAEC,gBAAgB,EAAQ;IACvE,OAAO,OAAOC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,EAAE;QACzC,IAAI;YACF,MAAMC,SAAS,MAAMR,cAAc;gBAAEG;gBAAYI;gBAAUF;YAAI;YAC/D,MAAMI,OAAOL,mBAAmBF,MAAM,CAACA,QAAQO,IAAI,CAACV,KAAKW,KAAK,CAACC,IAAI,CAACH,QAAQD;YAE5E,MAAM,CAACK,SAAS,GAAG,MAAMH,KAAKI,WAAW;YAEzC,sEAAsE;YACtE,MAAMC,iBAAiB,IAAIC,eAAe;gBACxCC,OAAMC,UAAU;oBACd,MAAMC,aAAaT,KAAKU,gBAAgB;oBACxCD,WAAWE,EAAE,CAAC,QAAQ,CAACC;wBACrBJ,WAAWK,OAAO,CAAC,IAAIC,WAAWF;oBACpC;oBACAH,WAAWE,EAAE,CAAC,OAAO;wBACnBH,WAAWO,KAAK;oBAClB;oBACAN,WAAWE,EAAE,CAAC,SAAS,CAACK;wBACtBR,WAAWS,KAAK,CAACD;oBACnB;gBACF;YACF;YAEA,OAAO,IAAIE,SAASb,gBAAgB;gBAClCc,SAAS,IAAIC,QAAQ;oBACnB,kBAAkBC,OAAOlB,SAASmB,IAAI;oBACtC,gBAAgBnB,SAASoB,WAAW;oBACpCC,MAAMrB,SAASsB,IAAI;gBACrB;gBACAC,QAAQ;YACV;QACF,EAAE,OAAOV,KAAc;YACrBpB,IAAI+B,OAAO,CAACC,MAAM,CAACX,KAAK,CAACD;YACzB,OAAO,IAAIE,SAAS,yBAAyB;gBAAEQ,QAAQ;YAAI;QAC7D;IACF;AACF,EAAC"}
|