@payloadcms/storage-azure 4.0.0-internal.d21c039 → 4.0.0-internal.d3909a9
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/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +16 -5
- package/dist/adapter.js.map +1 -1
- package/dist/copyFile.d.ts +11 -0
- package/dist/copyFile.d.ts.map +1 -0
- package/dist/copyFile.js +52 -0
- package/dist/copyFile.js.map +1 -0
- package/dist/getFile.d.ts +3 -2
- package/dist/getFile.d.ts.map +1 -1
- package/dist/getFile.js +5 -9
- package/dist/getFile.js.map +1 -1
- package/dist/isClientUploadAllowed.js.map +1 -1
- package/package.json +16 -18
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EACV,OAAO,EACP,mBAAmB,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EACV,OAAO,EACP,mBAAmB,EAGpB,MAAM,wCAAwC,CAAA;AAU/C,UAAU,sBAAsB;IAC9B,oBAAoB,EAAE,OAAO,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,aAAa,EAAE,MAAM,CAAA;IACrB,0BAA0B,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACtD,gBAAgB,EAAE,MAAM,eAAe,CAAA;IACvC,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,wBAAgB,kBAAkB,CAAC,EACjC,oBAAoB,EACpB,OAAO,EACP,aAAa,EACb,aAAa,EACb,0BAA0B,EAC1B,gBAAgB,EAChB,oBAA4B,GAC7B,EAAE,sBAAsB,GAAG,OAAO,CAmElC"}
|
package/dist/adapter.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { copyAzureFile } from './copyFile.js';
|
|
1
2
|
import { deleteFile } from './deleteFile.js';
|
|
2
3
|
import { generateUploadInstructions } from './generateUploadInstructions.js';
|
|
3
4
|
import { generateURL } from './generateURL.js';
|
|
@@ -5,8 +6,20 @@ import { getFile } from './getFile.js';
|
|
|
5
6
|
import { isClientUploadAllowed } from './isClientUploadAllowed.js';
|
|
6
7
|
import { uploadFile } from './uploadFile.js';
|
|
7
8
|
export function createAzureAdapter({ allowContainerCreate, baseURL, clientUploads, containerName, createContainerIfNotExists, getStorageClient, useCompositePrefixes = false }) {
|
|
9
|
+
const deleteStoredFile = ({ storageFilePath })=>deleteFile({
|
|
10
|
+
client: getStorageClient(),
|
|
11
|
+
storageFilePath
|
|
12
|
+
});
|
|
8
13
|
return ({ collection, prefix = '' })=>({
|
|
9
14
|
name: 'azure',
|
|
15
|
+
supportsTempFiles: true,
|
|
16
|
+
copyFile: ({ from, req, to })=>copyAzureFile({
|
|
17
|
+
client: getStorageClient(),
|
|
18
|
+
from,
|
|
19
|
+
req,
|
|
20
|
+
to
|
|
21
|
+
}),
|
|
22
|
+
deleteFile: deleteStoredFile,
|
|
10
23
|
generateURL: ({ filename, prefix: urlPrefix = '' })=>generateURL({
|
|
11
24
|
baseURL,
|
|
12
25
|
collectionPrefix: prefix,
|
|
@@ -30,10 +43,7 @@ export function createAzureAdapter({ allowContainerCreate, baseURL, clientUpload
|
|
|
30
43
|
requiresUploadReceipt: true,
|
|
31
44
|
useInAdmin: true
|
|
32
45
|
},
|
|
33
|
-
handleDelete:
|
|
34
|
-
client: getStorageClient(),
|
|
35
|
-
storageFilePath
|
|
36
|
-
}),
|
|
46
|
+
handleDelete: deleteStoredFile,
|
|
37
47
|
handleUpload: async ({ data, file, storageFilePath })=>{
|
|
38
48
|
await uploadFile({
|
|
39
49
|
buffer: file.buffer,
|
|
@@ -44,13 +54,14 @@ export function createAzureAdapter({ allowContainerCreate, baseURL, clientUpload
|
|
|
44
54
|
});
|
|
45
55
|
return data;
|
|
46
56
|
},
|
|
47
|
-
staticHandler: (req, { doc, headers, params: { filename, uploadReference } })=>getFile({
|
|
57
|
+
staticHandler: (req, { doc, headers, params: { filename, operation, uploadReference } })=>getFile({
|
|
48
58
|
client: getStorageClient(),
|
|
49
59
|
collection,
|
|
50
60
|
collectionPrefix: prefix,
|
|
51
61
|
doc,
|
|
52
62
|
filename,
|
|
53
63
|
incomingHeaders: headers,
|
|
64
|
+
operation,
|
|
54
65
|
req,
|
|
55
66
|
uploadReference,
|
|
56
67
|
useCompositePrefixes
|
package/dist/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapter.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type {\n Adapter,\n ClientUploadsConfig,\n GeneratedAdapter,\n} from '@payloadcms/plugin-cloud-storage/types'\n\nimport { deleteFile } from './deleteFile.js'\nimport { generateUploadInstructions } from './generateUploadInstructions.js'\nimport { generateURL } from './generateURL.js'\nimport { getFile } from './getFile.js'\nimport { isClientUploadAllowed } from './isClientUploadAllowed.js'\nimport { uploadFile } from './uploadFile.js'\n\ninterface CreateAzureAdapterArgs {\n allowContainerCreate: boolean\n baseURL: string\n clientUploads?: ClientUploadsConfig\n containerName: string\n createContainerIfNotExists: () => Promise<void> | void\n getStorageClient: () => ContainerClient\n useCompositePrefixes?: boolean\n}\n\nexport function createAzureAdapter({\n allowContainerCreate,\n baseURL,\n clientUploads,\n containerName,\n createContainerIfNotExists,\n getStorageClient,\n useCompositePrefixes = false,\n}: CreateAzureAdapterArgs): Adapter {\n return ({ collection, prefix = '' }): GeneratedAdapter => ({\n name: 'azure',\n\n generateURL: ({ filename, prefix: urlPrefix = '' }) =>\n generateURL({\n baseURL,\n collectionPrefix: prefix,\n containerName,\n filename,\n prefix: urlPrefix,\n useCompositePrefixes,\n }),\n\n uploadInstructions: {\n adminHandler: {\n path: '@payloadcms/storage-azure/client#AzureClientUploadHandler',\n },\n enabled: Boolean(clientUploads) && isClientUploadAllowed(collection),\n generate: generateUploadInstructions({\n access: typeof clientUploads === 'object' ? clientUploads.access : undefined,\n collectionPrefix: prefix,\n containerName,\n getStorageClient,\n useCompositePrefixes,\n }),\n requiresUploadReceipt: true,\n useInAdmin: true,\n },\n\n handleDelete:
|
|
1
|
+
{"version":3,"sources":["../src/adapter.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type {\n Adapter,\n ClientUploadsConfig,\n DeleteFile,\n GeneratedAdapter,\n} from '@payloadcms/plugin-cloud-storage/types'\n\nimport { copyAzureFile } from './copyFile.js'\nimport { deleteFile } from './deleteFile.js'\nimport { generateUploadInstructions } from './generateUploadInstructions.js'\nimport { generateURL } from './generateURL.js'\nimport { getFile } from './getFile.js'\nimport { isClientUploadAllowed } from './isClientUploadAllowed.js'\nimport { uploadFile } from './uploadFile.js'\n\ninterface CreateAzureAdapterArgs {\n allowContainerCreate: boolean\n baseURL: string\n clientUploads?: ClientUploadsConfig\n containerName: string\n createContainerIfNotExists: () => Promise<void> | void\n getStorageClient: () => ContainerClient\n useCompositePrefixes?: boolean\n}\n\nexport function createAzureAdapter({\n allowContainerCreate,\n baseURL,\n clientUploads,\n containerName,\n createContainerIfNotExists,\n getStorageClient,\n useCompositePrefixes = false,\n}: CreateAzureAdapterArgs): Adapter {\n const deleteStoredFile: DeleteFile = ({ storageFilePath }) =>\n deleteFile({ client: getStorageClient(), storageFilePath })\n\n return ({ collection, prefix = '' }): GeneratedAdapter => ({\n name: 'azure',\n supportsTempFiles: true,\n\n copyFile: ({ from, req, to }) => copyAzureFile({ client: getStorageClient(), from, req, to }),\n deleteFile: deleteStoredFile,\n\n generateURL: ({ filename, prefix: urlPrefix = '' }) =>\n generateURL({\n baseURL,\n collectionPrefix: prefix,\n containerName,\n filename,\n prefix: urlPrefix,\n useCompositePrefixes,\n }),\n\n uploadInstructions: {\n adminHandler: {\n path: '@payloadcms/storage-azure/client#AzureClientUploadHandler',\n },\n enabled: Boolean(clientUploads) && isClientUploadAllowed(collection),\n generate: generateUploadInstructions({\n access: typeof clientUploads === 'object' ? clientUploads.access : undefined,\n collectionPrefix: prefix,\n containerName,\n getStorageClient,\n useCompositePrefixes,\n }),\n requiresUploadReceipt: true,\n useInAdmin: true,\n },\n\n handleDelete: deleteStoredFile,\n\n handleUpload: async ({ data, file, storageFilePath }) => {\n await uploadFile({\n buffer: file.buffer,\n client: getStorageClient(),\n mimeType: file.mimeType,\n storageFilePath,\n tempFilePath: file.tempFilePath,\n })\n\n return data\n },\n\n staticHandler: (req, { doc, headers, params: { filename, operation, uploadReference } }) =>\n getFile({\n client: getStorageClient(),\n collection,\n collectionPrefix: prefix,\n doc,\n filename,\n incomingHeaders: headers,\n operation,\n req,\n uploadReference,\n useCompositePrefixes,\n }),\n\n ...(allowContainerCreate && { onInit: createContainerIfNotExists }),\n })\n}\n"],"names":["copyAzureFile","deleteFile","generateUploadInstructions","generateURL","getFile","isClientUploadAllowed","uploadFile","createAzureAdapter","allowContainerCreate","baseURL","clientUploads","containerName","createContainerIfNotExists","getStorageClient","useCompositePrefixes","deleteStoredFile","storageFilePath","client","collection","prefix","name","supportsTempFiles","copyFile","from","req","to","filename","urlPrefix","collectionPrefix","uploadInstructions","adminHandler","path","enabled","Boolean","generate","access","undefined","requiresUploadReceipt","useInAdmin","handleDelete","handleUpload","data","file","buffer","mimeType","tempFilePath","staticHandler","doc","headers","params","operation","uploadReference","incomingHeaders","onInit"],"mappings":"AAQA,SAASA,aAAa,QAAQ,gBAAe;AAC7C,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC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AEAK,eAAe,CAACtB,KAAK,EAAEuB,GAAG,EAAEC,OAAO,EAAEC,QAAQ,EAAEvB,QAAQ,EAAEwB,SAAS,EAAEC,eAAe,EAAE,EAAE,GACrF/C,QAAQ;oBACNa,QAAQJ;oBACRK;oBACAU,kBAAkBT;oBAClB4B;oBACArB;oBACA0B,iBAAiBJ;oBACjBE;oBACA1B;oBACA2B;oBACArC;gBACF;YAEF,GAAIN,wBAAwB;gBAAE6C,QAAQzC;YAA2B,CAAC;QACpE,CAAA;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ContainerClient } from '@azure/storage-blob';
|
|
2
|
+
import type { PayloadRequest } from 'payload';
|
|
3
|
+
type Args = {
|
|
4
|
+
client: ContainerClient;
|
|
5
|
+
from: string;
|
|
6
|
+
req?: PayloadRequest;
|
|
7
|
+
to: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const copyAzureFile: ({ client, from, req, to }: Args) => Promise<void>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=copyFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyFile.d.ts","sourceRoot":"","sources":["../src/copyFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,KAAK,IAAI,GAAG;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,cAAc,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvF,eAAO,MAAM,aAAa,8BAAqC,IAAI,KAAG,OAAO,CAAC,IAAI,CAqDjF,CAAA"}
|
package/dist/copyFile.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export const copyAzureFile = async ({ client, from, req, to })=>{
|
|
2
|
+
if (from === to) {
|
|
3
|
+
throw new Error('Storage copy requires different source and destination keys');
|
|
4
|
+
}
|
|
5
|
+
const source = client.getBlockBlobClient(from);
|
|
6
|
+
const destination = client.getBlockBlobClient(to);
|
|
7
|
+
const properties = await source.getProperties();
|
|
8
|
+
const { tags } = await source.getTags();
|
|
9
|
+
const download = await source.download();
|
|
10
|
+
if (!download.readableStreamBody) {
|
|
11
|
+
throw new Error(`Azure storage source is not readable: ${from}`);
|
|
12
|
+
}
|
|
13
|
+
const uploaded = await destination.uploadStream(download.readableStreamBody, 4 * 1024 * 1024, 4, {
|
|
14
|
+
blobHTTPHeaders: {
|
|
15
|
+
blobCacheControl: properties.cacheControl,
|
|
16
|
+
blobContentDisposition: properties.contentDisposition,
|
|
17
|
+
blobContentEncoding: properties.contentEncoding,
|
|
18
|
+
blobContentLanguage: properties.contentLanguage,
|
|
19
|
+
blobContentType: properties.contentType
|
|
20
|
+
},
|
|
21
|
+
conditions: {
|
|
22
|
+
ifNoneMatch: '*'
|
|
23
|
+
},
|
|
24
|
+
metadata: properties.metadata,
|
|
25
|
+
tags
|
|
26
|
+
});
|
|
27
|
+
try {
|
|
28
|
+
const copied = await destination.getProperties();
|
|
29
|
+
if (copied.contentLength !== properties.contentLength) {
|
|
30
|
+
throw new Error(`Copied Azure object is not readable at its expected length: ${to}`);
|
|
31
|
+
}
|
|
32
|
+
} catch (err) {
|
|
33
|
+
try {
|
|
34
|
+
if (!uploaded.etag) {
|
|
35
|
+
throw new Error('Azure copy did not return an ETag for safe cleanup');
|
|
36
|
+
}
|
|
37
|
+
await destination.deleteIfExists({
|
|
38
|
+
conditions: {
|
|
39
|
+
ifMatch: uploaded.etag
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
} catch (cleanupError) {
|
|
43
|
+
req?.payload.logger.error({
|
|
44
|
+
err: cleanupError,
|
|
45
|
+
msg: `Failed to remove unsuccessful Azure copy at ${client.containerName}/${to}`
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
throw err;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=copyFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/copyFile.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { Readable } from 'node:stream'\nimport type { PayloadRequest } from 'payload'\n\ntype Args = { client: ContainerClient; from: string; req?: PayloadRequest; to: string }\n\nexport const copyAzureFile = async ({ client, from, req, to }: Args): Promise<void> => {\n if (from === to) {\n throw new Error('Storage copy requires different source and destination keys')\n }\n\n const source = client.getBlockBlobClient(from)\n const destination = client.getBlockBlobClient(to)\n const properties = await source.getProperties()\n const { tags } = await source.getTags()\n const download = await source.download()\n\n if (!download.readableStreamBody) {\n throw new Error(`Azure storage source is not readable: ${from}`)\n }\n\n const uploaded = await destination.uploadStream(\n download.readableStreamBody as Readable,\n 4 * 1024 * 1024,\n 4,\n {\n blobHTTPHeaders: {\n blobCacheControl: properties.cacheControl,\n blobContentDisposition: properties.contentDisposition,\n blobContentEncoding: properties.contentEncoding,\n blobContentLanguage: properties.contentLanguage,\n blobContentType: properties.contentType,\n },\n conditions: { ifNoneMatch: '*' },\n metadata: properties.metadata,\n tags,\n },\n )\n\n try {\n const copied = await destination.getProperties()\n\n if (copied.contentLength !== properties.contentLength) {\n throw new Error(`Copied Azure object is not readable at its expected length: ${to}`)\n }\n } catch (err) {\n try {\n if (!uploaded.etag) {\n throw new Error('Azure copy did not return an ETag for safe cleanup')\n }\n await destination.deleteIfExists({ conditions: { ifMatch: uploaded.etag } })\n } catch (cleanupError) {\n req?.payload.logger.error({\n err: cleanupError,\n msg: `Failed to remove unsuccessful Azure copy at ${client.containerName}/${to}`,\n })\n }\n throw err\n }\n}\n"],"names":["copyAzureFile","client","from","req","to","Error","source","getBlockBlobClient","destination","properties","getProperties","tags","getTags","download","readableStreamBody","uploaded","uploadStream","blobHTTPHeaders","blobCacheControl","cacheControl","blobContentDisposition","contentDisposition","blobContentEncoding","contentEncoding","blobContentLanguage","contentLanguage","blobContentType","contentType","conditions","ifNoneMatch","metadata","copied","contentLength","err","etag","deleteIfExists","ifMatch","cleanupError","payload","logger","error","msg","containerName"],"mappings":"AAMA,OAAO,MAAMA,gBAAgB,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAEC,GAAG,EAAEC,EAAE,EAAQ;IACjE,IAAIF,SAASE,IAAI;QACf,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,SAASL,OAAOM,kBAAkB,CAACL;IACzC,MAAMM,cAAcP,OAAOM,kBAAkB,CAACH;IAC9C,MAAMK,aAAa,MAAMH,OAAOI,aAAa;IAC7C,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAML,OAAOM,OAAO;IACrC,MAAMC,WAAW,MAAMP,OAAOO,QAAQ;IAEtC,IAAI,CAACA,SAASC,kBAAkB,EAAE;QAChC,MAAM,IAAIT,MAAM,CAAC,sCAAsC,EAAEH,MAAM;IACjE;IAEA,MAAMa,WAAW,MAAMP,YAAYQ,YAAY,CAC7CH,SAASC,kBAAkB,EAC3B,IAAI,OAAO,MACX,GACA;QACEG,iBAAiB;YACfC,kBAAkBT,WAAWU,YAAY;YACzCC,wBAAwBX,WAAWY,kBAAkB;YACrDC,qBAAqBb,WAAWc,eAAe;YAC/CC,qBAAqBf,WAAWgB,eAAe;YAC/CC,iBAAiBjB,WAAWkB,WAAW;QACzC;QACAC,YAAY;YAAEC,aAAa;QAAI;QAC/BC,UAAUrB,WAAWqB,QAAQ;QAC7BnB;IACF;IAGF,IAAI;QACF,MAAMoB,SAAS,MAAMvB,YAAYE,aAAa;QAE9C,IAAIqB,OAAOC,aAAa,KAAKvB,WAAWuB,aAAa,EAAE;YACrD,MAAM,IAAI3B,MAAM,CAAC,4DAA4D,EAAED,IAAI;QACrF;IACF,EAAE,OAAO6B,KAAK;QACZ,IAAI;YACF,IAAI,CAAClB,SAASmB,IAAI,EAAE;gBAClB,MAAM,IAAI7B,MAAM;YAClB;YACA,MAAMG,YAAY2B,cAAc,CAAC;gBAAEP,YAAY;oBAAEQ,SAASrB,SAASmB,IAAI;gBAAC;YAAE;QAC5E,EAAE,OAAOG,cAAc;YACrBlC,KAAKmC,QAAQC,OAAOC,MAAM;gBACxBP,KAAKI;gBACLI,KAAK,CAAC,4CAA4C,EAAExC,OAAOyC,aAAa,CAAC,CAAC,EAAEtC,IAAI;YAClF;QACF;QACA,MAAM6B;IACR;AACF,EAAC"}
|
package/dist/getFile.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContainerClient } from '@azure/storage-blob';
|
|
2
|
-
import type { CollectionConfig, PayloadRequest, TypeWithID } from 'payload';
|
|
2
|
+
import type { CollectionConfig, FileHandlerOperation, PayloadRequest, TypeWithID } from 'payload';
|
|
3
3
|
interface GetFileArgs {
|
|
4
4
|
client: ContainerClient;
|
|
5
5
|
collection: CollectionConfig;
|
|
@@ -7,10 +7,11 @@ interface GetFileArgs {
|
|
|
7
7
|
doc?: TypeWithID;
|
|
8
8
|
filename: string;
|
|
9
9
|
incomingHeaders?: Headers;
|
|
10
|
+
operation?: FileHandlerOperation;
|
|
10
11
|
req: PayloadRequest;
|
|
11
12
|
uploadReference?: unknown;
|
|
12
13
|
useCompositePrefixes?: boolean;
|
|
13
14
|
}
|
|
14
|
-
export declare function getFile({ client, collection, collectionPrefix, doc, filename, incomingHeaders, req, uploadReference, useCompositePrefixes, }: GetFileArgs): Promise<Response>;
|
|
15
|
+
export declare function getFile({ client, collection, collectionPrefix, doc, filename, incomingHeaders, operation, req, uploadReference, useCompositePrefixes, }: GetFileArgs): Promise<Response>;
|
|
15
16
|
export {};
|
|
16
17
|
//# sourceMappingURL=getFile.d.ts.map
|
package/dist/getFile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../src/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8B,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../src/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8B,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAUjG,UAAU,WAAW;IACnB,MAAM,EAAE,eAAe,CAAA;IACvB,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,GAAG,CAAC,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,SAAS,CAAC,EAAE,oBAAoB,CAAA;IAChC,GAAG,EAAE,cAAc,CAAA;IACnB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAgCD,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,UAAU,EACV,gBAAqB,EACrB,GAAG,EACH,QAAQ,EACR,eAAe,EACf,SAAkB,EAClB,GAAG,EACH,eAAe,EACf,oBAA4B,GAC7B,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsHjC"}
|
package/dist/getFile.js
CHANGED
|
@@ -13,7 +13,8 @@ const abortRequestAndDestroyStream = ({ abortController, blob })=>{
|
|
|
13
13
|
blob.readableStreamBody.destroy();
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
export async function getFile({ client, collection, collectionPrefix = '', doc, filename, incomingHeaders, req, uploadReference, useCompositePrefixes = false }) {
|
|
16
|
+
export async function getFile({ client, collection, collectionPrefix = '', doc, filename, incomingHeaders, operation = 'read', req, uploadReference, useCompositePrefixes = false }) {
|
|
17
|
+
const isTransformSource = operation === 'transform';
|
|
17
18
|
let blob = undefined;
|
|
18
19
|
let streamed = false;
|
|
19
20
|
const abortController = new AbortController();
|
|
@@ -42,7 +43,6 @@ export async function getFile({ client, collection, collectionPrefix = '', doc,
|
|
|
42
43
|
useCompositePrefixes
|
|
43
44
|
});
|
|
44
45
|
const blockBlobClient = client.getBlockBlobClient(storageFilePath);
|
|
45
|
-
// Get file size for range validation
|
|
46
46
|
const properties = await blockBlobClient.getProperties();
|
|
47
47
|
const fileSize = properties.contentLength;
|
|
48
48
|
if (!fileSize) {
|
|
@@ -50,8 +50,7 @@ export async function getFile({ client, collection, collectionPrefix = '', doc,
|
|
|
50
50
|
status: 500
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
const rangeHeader = req.headers.get('range');
|
|
53
|
+
const rangeHeader = isTransformSource ? null : req.headers.get('range');
|
|
55
54
|
const rangeResult = getRangeRequestInfo({
|
|
56
55
|
fileSize,
|
|
57
56
|
rangeHeader
|
|
@@ -62,18 +61,15 @@ export async function getFile({ client, collection, collectionPrefix = '', doc,
|
|
|
62
61
|
status: rangeResult.status
|
|
63
62
|
});
|
|
64
63
|
}
|
|
65
|
-
// Download with range if partial
|
|
66
64
|
blob = rangeResult.type === 'partial' ? await blockBlobClient.download(rangeResult.rangeStart, rangeResult.rangeEnd - rangeResult.rangeStart + 1, {
|
|
67
65
|
abortSignal: abortController.signal
|
|
68
66
|
}) : await blockBlobClient.download(0, undefined, {
|
|
69
67
|
abortSignal: abortController.signal
|
|
70
68
|
});
|
|
71
69
|
let headers = new Headers(incomingHeaders);
|
|
72
|
-
// Add range-related headers from the result
|
|
73
70
|
for (const [key, value] of Object.entries(rangeResult.headers)){
|
|
74
71
|
headers.append(key, value);
|
|
75
72
|
}
|
|
76
|
-
// Add Azure-specific headers
|
|
77
73
|
headers.append('Content-Type', String(properties.contentType));
|
|
78
74
|
if (properties.etag) {
|
|
79
75
|
headers.append('ETag', String(properties.etag));
|
|
@@ -83,12 +79,12 @@ export async function getFile({ client, collection, collectionPrefix = '', doc,
|
|
|
83
79
|
headers.append('Content-Security-Policy', uploadContentSecurityPolicy);
|
|
84
80
|
}
|
|
85
81
|
const etagFromHeaders = req.headers.get('etag') || req.headers.get('if-none-match');
|
|
86
|
-
if (collection.upload && typeof collection.upload === 'object' && typeof collection.upload.modifyResponseHeaders === 'function') {
|
|
82
|
+
if (!isTransformSource && collection.upload && typeof collection.upload === 'object' && typeof collection.upload.modifyResponseHeaders === 'function') {
|
|
87
83
|
headers = collection.upload.modifyResponseHeaders({
|
|
88
84
|
headers
|
|
89
85
|
}) || headers;
|
|
90
86
|
}
|
|
91
|
-
if (etagFromHeaders && etagFromHeaders === properties.etag) {
|
|
87
|
+
if (!isTransformSource && etagFromHeaders && etagFromHeaders === properties.etag) {
|
|
92
88
|
return new Response(null, {
|
|
93
89
|
headers,
|
|
94
90
|
status: 304
|
package/dist/getFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/getFile.ts"],"sourcesContent":["import type { BlobDownloadResponseParsed, ContainerClient } from '@azure/storage-blob'\nimport type { CollectionConfig, PayloadRequest, TypeWithID } from 'payload'\nimport type { Readable } from 'stream'\n\nimport { RestError } from '@azure/storage-blob'\nimport {\n buildStoragePathData,\n getFilePrefix as getDocPrefix,\n} from '@payloadcms/plugin-cloud-storage/utilities'\nimport { getRangeRequestInfo, isXmlMimeType, uploadContentSecurityPolicy } from 'payload/internal'\n\ninterface GetFileArgs {\n client: ContainerClient\n collection: CollectionConfig\n collectionPrefix?: string\n doc?: TypeWithID\n filename: string\n incomingHeaders?: Headers\n req: PayloadRequest\n uploadReference?: unknown\n useCompositePrefixes?: boolean\n}\n\nconst isNodeReadableStream = (\n body: BlobDownloadResponseParsed['readableStreamBody'],\n): body is Readable => {\n return (\n typeof body === 'object' &&\n body !== null &&\n 'pipe' in body &&\n typeof body.pipe === 'function' &&\n 'destroy' in body &&\n typeof body.destroy === 'function'\n )\n}\n\nconst abortRequestAndDestroyStream = ({\n abortController,\n blob,\n}: {\n abortController: AbortController\n blob?: BlobDownloadResponseParsed\n}) => {\n try {\n abortController.abort()\n } catch {\n /* noop */\n }\n if (blob?.readableStreamBody && isNodeReadableStream(blob.readableStreamBody)) {\n blob.readableStreamBody.destroy()\n }\n}\n\nexport async function getFile({\n client,\n collection,\n collectionPrefix = '',\n doc,\n filename,\n incomingHeaders,\n req,\n uploadReference,\n useCompositePrefixes = false,\n}: GetFileArgs): Promise<Response> {\n let blob: BlobDownloadResponseParsed | undefined = undefined\n let streamed = false\n\n const abortController = new AbortController()\n if (req.signal) {\n req.signal.addEventListener('abort', () => {\n abortRequestAndDestroyStream({ abortController, blob })\n })\n }\n\n try {\n const docPrefix = await getDocPrefix({\n collection,\n collectionPrefix,\n doc,\n filename,\n req,\n uploadReference,\n useCompositePrefixes,\n })\n\n const { storageFilePath } = buildStoragePathData({\n collectionPrefix,\n docPrefix,\n filename,\n useCompositePrefixes,\n })\n\n const blockBlobClient = client.getBlockBlobClient(storageFilePath)\n\n
|
|
1
|
+
{"version":3,"sources":["../src/getFile.ts"],"sourcesContent":["import type { BlobDownloadResponseParsed, ContainerClient } from '@azure/storage-blob'\nimport type { CollectionConfig, FileHandlerOperation, PayloadRequest, TypeWithID } from 'payload'\nimport type { Readable } from 'stream'\n\nimport { RestError } from '@azure/storage-blob'\nimport {\n buildStoragePathData,\n getFilePrefix as getDocPrefix,\n} from '@payloadcms/plugin-cloud-storage/utilities'\nimport { getRangeRequestInfo, isXmlMimeType, uploadContentSecurityPolicy } from 'payload/internal'\n\ninterface GetFileArgs {\n client: ContainerClient\n collection: CollectionConfig\n collectionPrefix?: string\n doc?: TypeWithID\n filename: string\n incomingHeaders?: Headers\n operation?: FileHandlerOperation\n req: PayloadRequest\n uploadReference?: unknown\n useCompositePrefixes?: boolean\n}\n\nconst isNodeReadableStream = (\n body: BlobDownloadResponseParsed['readableStreamBody'],\n): body is Readable => {\n return (\n typeof body === 'object' &&\n body !== null &&\n 'pipe' in body &&\n typeof body.pipe === 'function' &&\n 'destroy' in body &&\n typeof body.destroy === 'function'\n )\n}\n\nconst abortRequestAndDestroyStream = ({\n abortController,\n blob,\n}: {\n abortController: AbortController\n blob?: BlobDownloadResponseParsed\n}) => {\n try {\n abortController.abort()\n } catch {\n /* noop */\n }\n if (blob?.readableStreamBody && isNodeReadableStream(blob.readableStreamBody)) {\n blob.readableStreamBody.destroy()\n }\n}\n\nexport async function getFile({\n client,\n collection,\n collectionPrefix = '',\n doc,\n filename,\n incomingHeaders,\n operation = 'read',\n req,\n uploadReference,\n useCompositePrefixes = false,\n}: GetFileArgs): Promise<Response> {\n const isTransformSource = operation === 'transform'\n let blob: BlobDownloadResponseParsed | undefined = undefined\n let streamed = false\n\n const abortController = new AbortController()\n if (req.signal) {\n req.signal.addEventListener('abort', () => {\n abortRequestAndDestroyStream({ abortController, blob })\n })\n }\n\n try {\n const docPrefix = await getDocPrefix({\n collection,\n collectionPrefix,\n doc,\n filename,\n req,\n uploadReference,\n useCompositePrefixes,\n })\n\n const { storageFilePath } = buildStoragePathData({\n collectionPrefix,\n docPrefix,\n filename,\n useCompositePrefixes,\n })\n\n const blockBlobClient = client.getBlockBlobClient(storageFilePath)\n\n const properties = await blockBlobClient.getProperties()\n const fileSize = properties.contentLength\n\n if (!fileSize) {\n return new Response('Internal Server Error', { status: 500 })\n }\n\n const rangeHeader = isTransformSource ? null : req.headers.get('range')\n const rangeResult = getRangeRequestInfo({ fileSize, rangeHeader })\n\n if (rangeResult.type === 'invalid') {\n return new Response(null, {\n headers: new Headers(rangeResult.headers),\n status: rangeResult.status,\n })\n }\n\n blob =\n rangeResult.type === 'partial'\n ? await blockBlobClient.download(\n rangeResult.rangeStart,\n rangeResult.rangeEnd - rangeResult.rangeStart + 1,\n { abortSignal: abortController.signal },\n )\n : await blockBlobClient.download(0, undefined, { abortSignal: abortController.signal })\n\n let headers = new Headers(incomingHeaders)\n\n for (const [key, value] of Object.entries(rangeResult.headers)) {\n headers.append(key, value)\n }\n\n headers.append('Content-Type', String(properties.contentType))\n if (properties.etag) {\n headers.append('ETag', String(properties.etag))\n }\n\n // Apply a restrictive policy to XML-family responses served through Payload.\n if (isXmlMimeType(properties.contentType)) {\n headers.append('Content-Security-Policy', uploadContentSecurityPolicy)\n }\n\n const etagFromHeaders = req.headers.get('etag') || req.headers.get('if-none-match')\n\n if (\n !isTransformSource &&\n collection.upload &&\n typeof collection.upload === 'object' &&\n typeof collection.upload.modifyResponseHeaders === 'function'\n ) {\n headers = collection.upload.modifyResponseHeaders({ headers }) || headers\n }\n\n if (!isTransformSource && etagFromHeaders && etagFromHeaders === properties.etag) {\n return new Response(null, {\n headers,\n status: 304,\n })\n }\n\n if (!blob.readableStreamBody || !isNodeReadableStream(blob.readableStreamBody)) {\n return new Response('Internal Server Error', { status: 500 })\n }\n\n const stream = blob.readableStreamBody\n stream.on('error', (err: Error) => {\n req.payload.logger.error({\n err,\n msg: 'Error while streaming Azure blob (aborting)',\n })\n abortRequestAndDestroyStream({ abortController, blob })\n })\n\n streamed = true\n return new Response(stream, { headers, status: rangeResult.status })\n } catch (err: unknown) {\n if (err instanceof RestError && err.statusCode === 404) {\n return new Response(null, { status: 404, statusText: 'Not Found' })\n }\n req.payload.logger.error(err)\n return new Response('Internal Server Error', { status: 500 })\n } finally {\n if (!streamed) {\n abortRequestAndDestroyStream({ abortController, blob })\n }\n }\n}\n"],"names":["RestError","buildStoragePathData","getFilePrefix","getDocPrefix","getRangeRequestInfo","isXmlMimeType","uploadContentSecurityPolicy","isNodeReadableStream","body","pipe","destroy","abortRequestAndDestroyStream","abortController","blob","abort","readableStreamBody","getFile","client","collection","collectionPrefix","doc","filename","incomingHeaders","operation","req","uploadReference","useCompositePrefixes","isTransformSource","undefined","streamed","AbortController","signal","addEventListener","docPrefix","storageFilePath","blockBlobClient","getBlockBlobClient","properties","getProperties","fileSize","contentLength","Response","status","rangeHeader","headers","get","rangeResult","type","Headers","download","rangeStart","rangeEnd","abortSignal","key","value","Object","entries","append","String","contentType","etag","etagFromHeaders","upload","modifyResponseHeaders","stream","on","err","payload","logger","error","msg","statusCode","statusText"],"mappings":"AAIA,SAASA,SAAS,QAAQ,sBAAqB;AAC/C,SACEC,oBAAoB,EACpBC,iBAAiBC,YAAY,QACxB,6CAA4C;AACnD,SAASC,mBAAmB,EAAEC,aAAa,EAAEC,2BAA2B,QAAQ,mBAAkB;AAelG,MAAMC,uBAAuB,CAC3BC;IAEA,OACE,OAAOA,SAAS,YAChBA,SAAS,QACT,UAAUA,QACV,OAAOA,KAAKC,IAAI,KAAK,cACrB,aAAaD,QACb,OAAOA,KAAKE,OAAO,KAAK;AAE5B;AAEA,MAAMC,+BAA+B,CAAC,EACpCC,eAAe,EACfC,IAAI,EAIL;IACC,IAAI;QACFD,gBAAgBE,KAAK;IACvB,EAAE,OAAM;IACN,QAAQ,GACV;IACA,IAAID,MAAME,sBAAsBR,qBAAqBM,KAAKE,kBAAkB,GAAG;QAC7EF,KAAKE,kBAAkB,CAACL,OAAO;IACjC;AACF;AAEA,OAAO,eAAeM,QAAQ,EAC5BC,MAAM,EACNC,UAAU,EACVC,mBAAmB,EAAE,EACrBC,GAAG,EACHC,QAAQ,EACRC,eAAe,EACfC,YAAY,MAAM,EAClBC,GAAG,EACHC,eAAe,EACfC,uBAAuB,KAAK,EAChB;IACZ,MAAMC,oBAAoBJ,cAAc;IACxC,IAAIV,OAA+Ce;IACnD,IAAIC,WAAW;IAEf,MAAMjB,kBAAkB,IAAIkB;IAC5B,IAAIN,IAAIO,MAAM,EAAE;QACdP,IAAIO,MAAM,CAACC,gBAAgB,CAAC,SAAS;YACnCrB,6BAA6B;gBAAEC;gBAAiBC;YAAK;QACvD;IACF;IAEA,IAAI;QACF,MAAMoB,YAAY,MAAM9B,aAAa;YACnCe;YACAC;YACAC;YACAC;YACAG;YACAC;YACAC;QACF;QAEA,MAAM,EAAEQ,eAAe,EAAE,GAAGjC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|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/isClientUploadAllowed.ts"],"sourcesContent":["export const isClientUploadAllowed = (collection?: {\n upload?: { allowRestrictedFileTypes?: boolean } | boolean\n}): boolean =>\n Boolean(\n collection &&\n
|
|
1
|
+
{"version":3,"sources":["../src/isClientUploadAllowed.ts"],"sourcesContent":["export const isClientUploadAllowed = (collection?: {\n upload?: { allowRestrictedFileTypes?: boolean } | boolean\n}): boolean =>\n Boolean(\n collection &&\n typeof collection.upload === 'object' &&\n collection.upload.allowRestrictedFileTypes,\n )\n"],"names":["isClientUploadAllowed","collection","Boolean","upload","allowRestrictedFileTypes"],"mappings":"AAAA,OAAO,MAAMA,wBAAwB,CAACC,aAGpCC,QACED,cACA,OAAOA,WAAWE,MAAM,KAAK,YAC7BF,WAAWE,MAAM,CAACC,wBAAwB,EAC3C"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/storage-azure",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.d3909a9",
|
|
4
4
|
"description": "Payload storage adapter for Azure Blob Storage",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/payloadcms/payload.git",
|
|
9
|
-
"directory": "packages/storage-azure"
|
|
10
|
-
},
|
|
11
6
|
"license": "MIT",
|
|
12
7
|
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
13
8
|
"maintainers": [
|
|
@@ -17,8 +12,18 @@
|
|
|
17
12
|
"url": "https://payloadcms.com"
|
|
18
13
|
}
|
|
19
14
|
],
|
|
20
|
-
"
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/payloadcms/payload.git",
|
|
18
|
+
"directory": "packages/storage-azure"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
21
23
|
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
22
27
|
"exports": {
|
|
23
28
|
".": {
|
|
24
29
|
"import": "./dist/index.js",
|
|
@@ -31,21 +36,16 @@
|
|
|
31
36
|
"default": "./dist/exports/client.js"
|
|
32
37
|
}
|
|
33
38
|
},
|
|
34
|
-
"main": "./dist/index.js",
|
|
35
|
-
"types": "./dist/index.d.ts",
|
|
36
|
-
"files": [
|
|
37
|
-
"dist"
|
|
38
|
-
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@azure/abort-controller": "^1.1.0",
|
|
41
41
|
"@azure/storage-blob": "^12.33.0",
|
|
42
|
-
"@payloadcms/plugin-cloud-storage": "4.0.0-internal.
|
|
42
|
+
"@payloadcms/plugin-cloud-storage": "4.0.0-internal.d3909a9"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"payload": "4.0.0-internal.
|
|
45
|
+
"payload": "4.0.0-internal.d3909a9"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"payload": "4.0.0-internal.
|
|
48
|
+
"payload": "4.0.0-internal.d3909a9"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=24.15.0"
|
|
@@ -56,8 +56,6 @@
|
|
|
56
56
|
"build:debug": "pnpm build",
|
|
57
57
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
58
58
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
59
|
-
"clean": "rimraf -g {dist,*.tsbuildinfo}"
|
|
60
|
-
"lint": "eslint .",
|
|
61
|
-
"lint:fix": "eslint . --fix"
|
|
59
|
+
"clean": "rimraf -g {dist,*.tsbuildinfo}"
|
|
62
60
|
}
|
|
63
61
|
}
|