@payloadcms/storage-azure 3.86.0-internal.ac46214 → 3.87.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/README.md +26 -1
- package/dist/client/AzureClientUploadHandler.d.ts +4 -1
- package/dist/client/AzureClientUploadHandler.d.ts.map +1 -1
- package/dist/client/AzureClientUploadHandler.js +10 -32
- package/dist/client/AzureClientUploadHandler.js.map +1 -1
- package/dist/client/handleAzureUpload.d.ts +20 -0
- package/dist/client/handleAzureUpload.d.ts.map +1 -0
- package/dist/client/handleAzureUpload.js +59 -0
- package/dist/client/handleAzureUpload.js.map +1 -0
- package/dist/client/handleAzureUpload.spec.d.ts +2 -0
- package/dist/client/handleAzureUpload.spec.d.ts.map +1 -0
- package/dist/client/handleAzureUpload.spec.js +187 -0
- package/dist/client/handleAzureUpload.spec.js.map +1 -0
- package/dist/generateSignedURL.js +1 -1
- package/dist/generateSignedURL.js.map +1 -1
- package/dist/index.d.ts +20 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -14,7 +14,32 @@ pnpm add @payloadcms/storage-azure
|
|
|
14
14
|
|
|
15
15
|
- Configure the `collections` object to specify which collections should use the Azure Blob Storage adapter. The slug _must_ match one of your existing collection slugs.
|
|
16
16
|
- When enabled, this package will automatically set `disableLocalStorage` to `true` for each collection.
|
|
17
|
-
- When deploying to Vercel, server uploads are limited with 4.5MB. Set `clientUploads` to `true` to do uploads directly on the client.
|
|
17
|
+
- When deploying to Vercel, server uploads are limited with 4.5MB. Set `clientUploads` to `true` to do uploads directly on the client.
|
|
18
|
+
|
|
19
|
+
### Large client uploads (files over ~5GB)
|
|
20
|
+
|
|
21
|
+
By default, client uploads (`clientUploads: true`) send each file in a single request, which Azure caps at ~5GB. To upload larger files, set `chunkLargeFiles: true`:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
azureStorage({
|
|
25
|
+
// ...
|
|
26
|
+
clientUploads: {
|
|
27
|
+
chunkLargeFiles: true,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This uploads through the Azure Blob SDK, which splits the file into blocks (`Put Block` + `Put Block List`) and raises the limit to Azure's block-blob maximum (~190TiB).
|
|
33
|
+
|
|
34
|
+
Because the SDK sends additional `x-ms-*` headers, the browser issues a CORS preflight, so your storage account's CORS rules must allow the `OPTIONS` and `PUT` methods **and** those headers. Configure a CORS rule on the Blob service (Storage account → **Resource sharing (CORS)**):
|
|
35
|
+
|
|
36
|
+
| Field | Value |
|
|
37
|
+
| --------------- | -------------------------------------------------------- |
|
|
38
|
+
| Allowed origins | Your site origin (e.g. `https://example.com`) |
|
|
39
|
+
| Allowed methods | `GET,PUT,OPTIONS` (add `HEAD` if reading in-browser) |
|
|
40
|
+
| Allowed headers | `*` (or at minimum `x-ms-*,content-type,content-length`) |
|
|
41
|
+
| Exposed headers | `*` |
|
|
42
|
+
| Max age | `3600` |
|
|
18
43
|
|
|
19
44
|
```ts
|
|
20
45
|
import { azureStorage } from '@payloadcms/storage-azure'
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
export type AzureClientUploadHandlerExtra = {
|
|
2
|
+
chunkLargeFiles: boolean;
|
|
3
|
+
};
|
|
1
4
|
export declare const AzureClientUploadHandler: ({ children, collectionSlug, enabled, extra, prefix, serverHandlerPath, }: {
|
|
2
5
|
children: import("react").ReactNode;
|
|
3
6
|
collectionSlug: import("packages/payload/src/index.js").UploadCollectionSlug;
|
|
4
7
|
enabled?: boolean;
|
|
5
|
-
extra:
|
|
8
|
+
extra: AzureClientUploadHandlerExtra;
|
|
6
9
|
prefix?: string;
|
|
7
10
|
serverHandlerPath: `/${string}`;
|
|
8
11
|
}) => import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureClientUploadHandler.d.ts","sourceRoot":"","sources":["../../src/client/AzureClientUploadHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AzureClientUploadHandler.d.ts","sourceRoot":"","sources":["../../src/client/AzureClientUploadHandler.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,wBAAwB;;;;;;;aAuBgI,OAAO,aAD1K,CAAA"}
|
|
@@ -1,40 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { createClientUploadHandler } from '@payloadcms/plugin-cloud-storage/client';
|
|
3
|
-
import {
|
|
3
|
+
import { handleAzureUpload } from './handleAzureUpload.js';
|
|
4
4
|
export const AzureClientUploadHandler = createClientUploadHandler({
|
|
5
|
-
handler: async ({ apiRoute, collectionSlug, docPrefix, file, serverHandlerPath, serverURL, updateFilename })=>{
|
|
6
|
-
|
|
5
|
+
handler: async ({ apiRoute, collectionSlug, docPrefix, extra: { chunkLargeFiles }, file, serverHandlerPath, serverURL, updateFilename })=>{
|
|
6
|
+
return handleAzureUpload({
|
|
7
7
|
apiRoute,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
chunkLargeFiles,
|
|
9
|
+
collectionSlug,
|
|
10
|
+
docPrefix,
|
|
11
|
+
file,
|
|
12
|
+
serverHandlerPath,
|
|
13
|
+
serverURL,
|
|
14
|
+
updateFilename
|
|
10
15
|
});
|
|
11
|
-
const response = await fetch(endpointRoute, {
|
|
12
|
-
body: JSON.stringify({
|
|
13
|
-
collectionSlug,
|
|
14
|
-
docPrefix,
|
|
15
|
-
filename: file.name,
|
|
16
|
-
mimeType: file.type
|
|
17
|
-
}),
|
|
18
|
-
credentials: 'include',
|
|
19
|
-
method: 'POST'
|
|
20
|
-
});
|
|
21
|
-
const { docPrefix: sanitizedDocPrefix, filename: sanitizedFilename, url } = await response.json();
|
|
22
|
-
if (sanitizedFilename && sanitizedFilename !== file.name) {
|
|
23
|
-
updateFilename(sanitizedFilename);
|
|
24
|
-
}
|
|
25
|
-
await fetch(url, {
|
|
26
|
-
body: file,
|
|
27
|
-
headers: {
|
|
28
|
-
'Content-Length': file.size.toString(),
|
|
29
|
-
'Content-Type': file.type,
|
|
30
|
-
// Required for azure
|
|
31
|
-
'x-ms-blob-type': 'BlockBlob'
|
|
32
|
-
},
|
|
33
|
-
method: 'PUT'
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
prefix: sanitizedDocPrefix
|
|
37
|
-
};
|
|
38
16
|
}
|
|
39
17
|
});
|
|
40
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/AzureClientUploadHandler.ts"],"sourcesContent":["'use client'\nimport { createClientUploadHandler } from '@payloadcms/plugin-cloud-storage/client'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/client/AzureClientUploadHandler.ts"],"sourcesContent":["'use client'\nimport { createClientUploadHandler } from '@payloadcms/plugin-cloud-storage/client'\n\nimport { handleAzureUpload } from './handleAzureUpload.js'\n\nexport type AzureClientUploadHandlerExtra = {\n chunkLargeFiles: boolean\n}\n\nexport const AzureClientUploadHandler = createClientUploadHandler<AzureClientUploadHandlerExtra>({\n handler: async ({\n apiRoute,\n collectionSlug,\n docPrefix,\n extra: { chunkLargeFiles },\n file,\n serverHandlerPath,\n serverURL,\n updateFilename,\n }) => {\n return handleAzureUpload({\n apiRoute,\n chunkLargeFiles,\n collectionSlug,\n docPrefix,\n file,\n serverHandlerPath,\n serverURL,\n updateFilename,\n })\n },\n})\n"],"names":["createClientUploadHandler","handleAzureUpload","AzureClientUploadHandler","handler","apiRoute","collectionSlug","docPrefix","extra","chunkLargeFiles","file","serverHandlerPath","serverURL","updateFilename"],"mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,0CAAyC;AAEnF,SAASC,iBAAiB,QAAQ,yBAAwB;AAM1D,OAAO,MAAMC,2BAA2BF,0BAAyD;IAC/FG,SAAS,OAAO,EACdC,QAAQ,EACRC,cAAc,EACdC,SAAS,EACTC,OAAO,EAAEC,eAAe,EAAE,EAC1BC,IAAI,EACJC,iBAAiB,EACjBC,SAAS,EACTC,cAAc,EACf;QACC,OAAOX,kBAAkB;YACvBG;YACAI;YACAH;YACAC;YACAG;YACAC;YACAC;YACAC;QACF;IACF;AACF,GAAE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type HandleAzureUploadArgs = {
|
|
2
|
+
apiRoute: string;
|
|
3
|
+
/**
|
|
4
|
+
* When true, upload through the Azure Blob SDK, which splits the file into
|
|
5
|
+
* blocks (Put Block + Put Block List) and lifts the ~5 GB single-request
|
|
6
|
+
* limit. When false, use the legacy single Put Blob request.
|
|
7
|
+
*/
|
|
8
|
+
chunkLargeFiles: boolean;
|
|
9
|
+
collectionSlug: string;
|
|
10
|
+
docPrefix?: string;
|
|
11
|
+
file: File;
|
|
12
|
+
serverHandlerPath: `/${string}`;
|
|
13
|
+
serverURL: string;
|
|
14
|
+
updateFilename: (value: string) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare const handleAzureUpload: ({ apiRoute, chunkLargeFiles, collectionSlug, docPrefix, file, serverHandlerPath, serverURL, updateFilename, }: HandleAzureUploadArgs) => Promise<{
|
|
17
|
+
prefix: string;
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=handleAzureUpload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleAzureUpload.d.ts","sourceRoot":"","sources":["../../src/client/handleAzureUpload.ts"],"names":[],"mappings":"AAQA,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,eAAe,EAAE,OAAO,CAAA;IACxB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,IAAI,CAAA;IACV,iBAAiB,EAAE,IAAI,MAAM,EAAE,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC,CAAA;AAED,eAAO,MAAM,iBAAiB,kHAS3B,qBAAqB,KAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CA8DpD,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { formatAdminURL } from 'payload/shared';
|
|
3
|
+
// Balances upload parallelism against browser memory: `blockSize * concurrency`
|
|
4
|
+
// bytes are buffered in flight (64 MiB * 4 = 256 MiB). Only used on the SDK path.
|
|
5
|
+
const BLOCK_SIZE = 64 * 1024 * 1024;
|
|
6
|
+
const CONCURRENCY = 4;
|
|
7
|
+
export const handleAzureUpload = async ({ apiRoute, chunkLargeFiles, collectionSlug, docPrefix, file, serverHandlerPath, serverURL, updateFilename })=>{
|
|
8
|
+
const endpointRoute = formatAdminURL({
|
|
9
|
+
apiRoute,
|
|
10
|
+
path: serverHandlerPath,
|
|
11
|
+
serverURL
|
|
12
|
+
});
|
|
13
|
+
const response = await fetch(endpointRoute, {
|
|
14
|
+
body: JSON.stringify({
|
|
15
|
+
collectionSlug,
|
|
16
|
+
docPrefix,
|
|
17
|
+
filename: file.name,
|
|
18
|
+
mimeType: file.type
|
|
19
|
+
}),
|
|
20
|
+
credentials: 'include',
|
|
21
|
+
method: 'POST'
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
throw new Error('Failed to retrieve signed URL for Azure client upload');
|
|
25
|
+
}
|
|
26
|
+
const { docPrefix: sanitizedDocPrefix, filename: sanitizedFilename, url } = await response.json();
|
|
27
|
+
if (sanitizedFilename && sanitizedFilename !== file.name) {
|
|
28
|
+
updateFilename(sanitizedFilename);
|
|
29
|
+
}
|
|
30
|
+
if (chunkLargeFiles) {
|
|
31
|
+
// Loaded on demand so @azure/storage-blob is only pulled into the client bundle
|
|
32
|
+
// when a chunked client upload actually runs, rather than for every Azure user.
|
|
33
|
+
const { BlockBlobClient } = await import('@azure/storage-blob');
|
|
34
|
+
const blockBlobClient = new BlockBlobClient(url);
|
|
35
|
+
await blockBlobClient.uploadData(file, {
|
|
36
|
+
blobHTTPHeaders: {
|
|
37
|
+
blobContentType: file.type
|
|
38
|
+
},
|
|
39
|
+
blockSize: BLOCK_SIZE,
|
|
40
|
+
concurrency: CONCURRENCY
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
await fetch(url, {
|
|
44
|
+
body: file,
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Length': file.size.toString(),
|
|
47
|
+
'Content-Type': file.type,
|
|
48
|
+
// Required for azure
|
|
49
|
+
'x-ms-blob-type': 'BlockBlob'
|
|
50
|
+
},
|
|
51
|
+
method: 'PUT'
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
prefix: sanitizedDocPrefix
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=handleAzureUpload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/handleAzureUpload.ts"],"sourcesContent":["'use client'\nimport { formatAdminURL } from 'payload/shared'\n\n// Balances upload parallelism against browser memory: `blockSize * concurrency`\n// bytes are buffered in flight (64 MiB * 4 = 256 MiB). Only used on the SDK path.\nconst BLOCK_SIZE = 64 * 1024 * 1024\nconst CONCURRENCY = 4\n\ntype HandleAzureUploadArgs = {\n apiRoute: string\n /**\n * When true, upload through the Azure Blob SDK, which splits the file into\n * blocks (Put Block + Put Block List) and lifts the ~5 GB single-request\n * limit. When false, use the legacy single Put Blob request.\n */\n chunkLargeFiles: boolean\n collectionSlug: string\n docPrefix?: string\n file: File\n serverHandlerPath: `/${string}`\n serverURL: string\n updateFilename: (value: string) => void\n}\n\nexport const handleAzureUpload = async ({\n apiRoute,\n chunkLargeFiles,\n collectionSlug,\n docPrefix,\n file,\n serverHandlerPath,\n serverURL,\n updateFilename,\n}: HandleAzureUploadArgs): Promise<{ prefix: string }> => {\n const endpointRoute = formatAdminURL({\n apiRoute,\n path: serverHandlerPath,\n serverURL,\n })\n\n const response = await fetch(endpointRoute, {\n body: JSON.stringify({\n collectionSlug,\n docPrefix,\n filename: file.name,\n mimeType: file.type,\n }),\n credentials: 'include',\n method: 'POST',\n })\n\n if (!response.ok) {\n throw new Error('Failed to retrieve signed URL for Azure client upload')\n }\n\n const {\n docPrefix: sanitizedDocPrefix,\n filename: sanitizedFilename,\n url,\n } = (await response.json()) as {\n docPrefix: string\n filename?: string\n url: string\n }\n\n if (sanitizedFilename && sanitizedFilename !== file.name) {\n updateFilename(sanitizedFilename)\n }\n\n if (chunkLargeFiles) {\n // Loaded on demand so @azure/storage-blob is only pulled into the client bundle\n // when a chunked client upload actually runs, rather than for every Azure user.\n const { BlockBlobClient } = await import('@azure/storage-blob')\n\n const blockBlobClient = new BlockBlobClient(url)\n\n await blockBlobClient.uploadData(file, {\n blobHTTPHeaders: { blobContentType: file.type },\n blockSize: BLOCK_SIZE,\n concurrency: CONCURRENCY,\n })\n } else {\n await fetch(url, {\n body: file,\n headers: {\n 'Content-Length': file.size.toString(),\n 'Content-Type': file.type,\n // Required for azure\n 'x-ms-blob-type': 'BlockBlob',\n },\n method: 'PUT',\n })\n }\n\n return { prefix: sanitizedDocPrefix }\n}\n"],"names":["formatAdminURL","BLOCK_SIZE","CONCURRENCY","handleAzureUpload","apiRoute","chunkLargeFiles","collectionSlug","docPrefix","file","serverHandlerPath","serverURL","updateFilename","endpointRoute","path","response","fetch","body","JSON","stringify","filename","name","mimeType","type","credentials","method","ok","Error","sanitizedDocPrefix","sanitizedFilename","url","json","BlockBlobClient","blockBlobClient","uploadData","blobHTTPHeaders","blobContentType","blockSize","concurrency","headers","size","toString","prefix"],"mappings":"AAAA;AACA,SAASA,cAAc,QAAQ,iBAAgB;AAE/C,gFAAgF;AAChF,kFAAkF;AAClF,MAAMC,aAAa,KAAK,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version":3,"file":"handleAzureUpload.spec.d.ts","sourceRoot":"","sources":["../../src/client/handleAzureUpload.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
const uploadDataMock = vi.fn();
|
|
3
|
+
const blockBlobClientMock = vi.fn(function() {
|
|
4
|
+
return {
|
|
5
|
+
uploadData: uploadDataMock
|
|
6
|
+
};
|
|
7
|
+
});
|
|
8
|
+
vi.mock('@azure/storage-blob', ()=>({
|
|
9
|
+
BlockBlobClient: blockBlobClientMock
|
|
10
|
+
}));
|
|
11
|
+
import { handleAzureUpload } from './handleAzureUpload.js';
|
|
12
|
+
const serverURL = 'https://example.com';
|
|
13
|
+
const apiRoute = '/api';
|
|
14
|
+
const serverHandlerPath = '/storage-azure-generate-signed-url';
|
|
15
|
+
const signedURL = 'https://account.blob.core.windows.net/container/file.png?sig=abc';
|
|
16
|
+
const createFile = ()=>new File([
|
|
17
|
+
new Uint8Array([
|
|
18
|
+
1,
|
|
19
|
+
2,
|
|
20
|
+
3
|
|
21
|
+
])
|
|
22
|
+
], 'file.png', {
|
|
23
|
+
type: 'image/png'
|
|
24
|
+
});
|
|
25
|
+
const mockSignedURLResponse = (body, ok = true)=>{
|
|
26
|
+
const fetchMock = vi.fn().mockResolvedValue({
|
|
27
|
+
json: ()=>Promise.resolve(body),
|
|
28
|
+
ok
|
|
29
|
+
});
|
|
30
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
31
|
+
return fetchMock;
|
|
32
|
+
};
|
|
33
|
+
const invoke = (overrides = {})=>handleAzureUpload({
|
|
34
|
+
apiRoute,
|
|
35
|
+
chunkLargeFiles: true,
|
|
36
|
+
collectionSlug: 'media',
|
|
37
|
+
file: createFile(),
|
|
38
|
+
serverHandlerPath,
|
|
39
|
+
serverURL,
|
|
40
|
+
updateFilename: vi.fn(),
|
|
41
|
+
...overrides
|
|
42
|
+
});
|
|
43
|
+
describe('handleAzureUpload', ()=>{
|
|
44
|
+
beforeEach(()=>{
|
|
45
|
+
vi.clearAllMocks();
|
|
46
|
+
vi.unstubAllGlobals();
|
|
47
|
+
uploadDataMock.mockResolvedValue(undefined);
|
|
48
|
+
});
|
|
49
|
+
describe('shared behavior', ()=>{
|
|
50
|
+
it('should request a signed URL from the server handler', async ()=>{
|
|
51
|
+
const fetchMock = mockSignedURLResponse({
|
|
52
|
+
docPrefix: 'docs',
|
|
53
|
+
url: signedURL
|
|
54
|
+
});
|
|
55
|
+
await invoke({
|
|
56
|
+
docPrefix: 'docs'
|
|
57
|
+
});
|
|
58
|
+
const [calledURL, init] = fetchMock.mock.calls[0];
|
|
59
|
+
expect(calledURL).toBe(`${serverURL}${apiRoute}${serverHandlerPath}`);
|
|
60
|
+
expect(init.method).toBe('POST');
|
|
61
|
+
expect(JSON.parse(init.body)).toEqual({
|
|
62
|
+
collectionSlug: 'media',
|
|
63
|
+
docPrefix: 'docs',
|
|
64
|
+
filename: 'file.png',
|
|
65
|
+
mimeType: 'image/png'
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
it('should call updateFilename when the server returns a sanitized filename', async ()=>{
|
|
69
|
+
mockSignedURLResponse({
|
|
70
|
+
docPrefix: 'docs',
|
|
71
|
+
filename: 'file-1.png',
|
|
72
|
+
url: signedURL
|
|
73
|
+
});
|
|
74
|
+
const updateFilename = vi.fn();
|
|
75
|
+
await invoke({
|
|
76
|
+
updateFilename
|
|
77
|
+
});
|
|
78
|
+
expect(updateFilename).toHaveBeenCalledWith('file-1.png');
|
|
79
|
+
});
|
|
80
|
+
it('should not call updateFilename when the filename is unchanged', async ()=>{
|
|
81
|
+
mockSignedURLResponse({
|
|
82
|
+
docPrefix: 'docs',
|
|
83
|
+
filename: 'file.png',
|
|
84
|
+
url: signedURL
|
|
85
|
+
});
|
|
86
|
+
const updateFilename = vi.fn();
|
|
87
|
+
await invoke({
|
|
88
|
+
updateFilename
|
|
89
|
+
});
|
|
90
|
+
expect(updateFilename).not.toHaveBeenCalled();
|
|
91
|
+
});
|
|
92
|
+
it('should return the sanitized doc prefix', async ()=>{
|
|
93
|
+
mockSignedURLResponse({
|
|
94
|
+
docPrefix: 'sanitized-docs',
|
|
95
|
+
url: signedURL
|
|
96
|
+
});
|
|
97
|
+
const result = await invoke();
|
|
98
|
+
expect(result).toEqual({
|
|
99
|
+
prefix: 'sanitized-docs'
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
it('should throw when the signed URL request fails, before any upload', async ()=>{
|
|
103
|
+
mockSignedURLResponse({}, false);
|
|
104
|
+
await expect(invoke()).rejects.toThrow();
|
|
105
|
+
expect(uploadDataMock).not.toHaveBeenCalled();
|
|
106
|
+
expect(blockBlobClientMock).not.toHaveBeenCalled();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
describe('chunkLargeFiles: true (SDK block upload)', ()=>{
|
|
110
|
+
it('should upload via BlockBlobClient.uploadData rather than a raw PUT', async ()=>{
|
|
111
|
+
const fetchMock = mockSignedURLResponse({
|
|
112
|
+
docPrefix: 'docs',
|
|
113
|
+
url: signedURL
|
|
114
|
+
});
|
|
115
|
+
const file = createFile();
|
|
116
|
+
await invoke({
|
|
117
|
+
chunkLargeFiles: true,
|
|
118
|
+
file
|
|
119
|
+
});
|
|
120
|
+
expect(blockBlobClientMock).toHaveBeenCalledWith(signedURL);
|
|
121
|
+
expect(uploadDataMock).toHaveBeenCalledTimes(1);
|
|
122
|
+
const [uploadedFile, options] = uploadDataMock.mock.calls[0];
|
|
123
|
+
expect(uploadedFile).toBe(file);
|
|
124
|
+
expect(options.blockSize).toBeGreaterThan(0);
|
|
125
|
+
expect(options.concurrency).toBeGreaterThan(0);
|
|
126
|
+
// Only the signed-URL request should hit fetch; no raw PUT to the blob URL.
|
|
127
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
128
|
+
});
|
|
129
|
+
it('should pass the file content type to the blob headers', async ()=>{
|
|
130
|
+
mockSignedURLResponse({
|
|
131
|
+
docPrefix: 'docs',
|
|
132
|
+
url: signedURL
|
|
133
|
+
});
|
|
134
|
+
await invoke({
|
|
135
|
+
chunkLargeFiles: true
|
|
136
|
+
});
|
|
137
|
+
const [, options] = uploadDataMock.mock.calls[0];
|
|
138
|
+
expect(options.blobHTTPHeaders).toEqual({
|
|
139
|
+
blobContentType: 'image/png'
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
it('should propagate errors from uploadData', async ()=>{
|
|
143
|
+
mockSignedURLResponse({
|
|
144
|
+
docPrefix: 'docs',
|
|
145
|
+
url: signedURL
|
|
146
|
+
});
|
|
147
|
+
uploadDataMock.mockRejectedValue(new Error('block upload failed'));
|
|
148
|
+
await expect(invoke({
|
|
149
|
+
chunkLargeFiles: true
|
|
150
|
+
})).rejects.toThrow('block upload failed');
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
describe('chunkLargeFiles: false (single PUT, default/legacy)', ()=>{
|
|
154
|
+
it('should upload via a single raw PUT with the BlockBlob header', async ()=>{
|
|
155
|
+
const fetchMock = mockSignedURLResponse({
|
|
156
|
+
docPrefix: 'docs',
|
|
157
|
+
url: signedURL
|
|
158
|
+
});
|
|
159
|
+
const file = createFile();
|
|
160
|
+
await invoke({
|
|
161
|
+
chunkLargeFiles: false,
|
|
162
|
+
file
|
|
163
|
+
});
|
|
164
|
+
// 1st fetch = signed-URL POST, 2nd = the raw PUT to the blob URL
|
|
165
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
166
|
+
const [putURL, putInit] = fetchMock.mock.calls[1];
|
|
167
|
+
expect(putURL).toBe(signedURL);
|
|
168
|
+
expect(putInit.method).toBe('PUT');
|
|
169
|
+
expect(putInit.body).toBe(file);
|
|
170
|
+
expect(putInit.headers['x-ms-blob-type']).toBe('BlockBlob');
|
|
171
|
+
expect(putInit.headers['Content-Type']).toBe('image/png');
|
|
172
|
+
});
|
|
173
|
+
it('should not use the Azure SDK', async ()=>{
|
|
174
|
+
mockSignedURLResponse({
|
|
175
|
+
docPrefix: 'docs',
|
|
176
|
+
url: signedURL
|
|
177
|
+
});
|
|
178
|
+
await invoke({
|
|
179
|
+
chunkLargeFiles: false
|
|
180
|
+
});
|
|
181
|
+
expect(blockBlobClientMock).not.toHaveBeenCalled();
|
|
182
|
+
expect(uploadDataMock).not.toHaveBeenCalled();
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
//# sourceMappingURL=handleAzureUpload.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/handleAzureUpload.spec.ts"],"sourcesContent":["import { beforeEach, describe, expect, it, vi } from 'vitest'\n\nconst uploadDataMock = vi.fn()\nconst blockBlobClientMock = vi.fn(function () {\n return { uploadData: uploadDataMock }\n})\n\nvi.mock('@azure/storage-blob', () => ({\n BlockBlobClient: blockBlobClientMock,\n}))\n\nimport { handleAzureUpload } from './handleAzureUpload.js'\n\nconst serverURL = 'https://example.com'\nconst apiRoute = '/api'\nconst serverHandlerPath = '/storage-azure-generate-signed-url' as const\nconst signedURL = 'https://account.blob.core.windows.net/container/file.png?sig=abc'\n\nconst createFile = () => new File([new Uint8Array([1, 2, 3])], 'file.png', { type: 'image/png' })\n\nconst mockSignedURLResponse = (body: Record<string, unknown>, ok = true) => {\n const fetchMock = vi.fn().mockResolvedValue({\n json: () => Promise.resolve(body),\n ok,\n })\n vi.stubGlobal('fetch', fetchMock)\n return fetchMock\n}\n\nconst invoke = (overrides: Partial<Parameters<typeof handleAzureUpload>[0]> = {}) =>\n handleAzureUpload({\n apiRoute,\n chunkLargeFiles: true,\n collectionSlug: 'media',\n file: createFile(),\n serverHandlerPath,\n serverURL,\n updateFilename: vi.fn(),\n ...overrides,\n })\n\ndescribe('handleAzureUpload', () => {\n beforeEach(() => {\n vi.clearAllMocks()\n vi.unstubAllGlobals()\n uploadDataMock.mockResolvedValue(undefined)\n })\n\n describe('shared behavior', () => {\n it('should request a signed URL from the server handler', async () => {\n const fetchMock = mockSignedURLResponse({ docPrefix: 'docs', url: signedURL })\n\n await invoke({ docPrefix: 'docs' })\n\n const [calledURL, init] = fetchMock.mock.calls[0]!\n expect(calledURL).toBe(`${serverURL}${apiRoute}${serverHandlerPath}`)\n expect(init.method).toBe('POST')\n expect(JSON.parse(init.body)).toEqual({\n collectionSlug: 'media',\n docPrefix: 'docs',\n filename: 'file.png',\n mimeType: 'image/png',\n })\n })\n\n it('should call updateFilename when the server returns a sanitized filename', async () => {\n mockSignedURLResponse({ docPrefix: 'docs', filename: 'file-1.png', url: signedURL })\n const updateFilename = vi.fn()\n\n await invoke({ updateFilename })\n\n expect(updateFilename).toHaveBeenCalledWith('file-1.png')\n })\n\n it('should not call updateFilename when the filename is unchanged', async () => {\n mockSignedURLResponse({ docPrefix: 'docs', filename: 'file.png', url: signedURL })\n const updateFilename = vi.fn()\n\n await invoke({ updateFilename })\n\n expect(updateFilename).not.toHaveBeenCalled()\n })\n\n it('should return the sanitized doc prefix', async () => {\n mockSignedURLResponse({ docPrefix: 'sanitized-docs', url: signedURL })\n\n const result = await invoke()\n\n expect(result).toEqual({ prefix: 'sanitized-docs' })\n })\n\n it('should throw when the signed URL request fails, before any upload', async () => {\n mockSignedURLResponse({}, false)\n\n await expect(invoke()).rejects.toThrow()\n\n expect(uploadDataMock).not.toHaveBeenCalled()\n expect(blockBlobClientMock).not.toHaveBeenCalled()\n })\n })\n\n describe('chunkLargeFiles: true (SDK block upload)', () => {\n it('should upload via BlockBlobClient.uploadData rather than a raw PUT', async () => {\n const fetchMock = mockSignedURLResponse({ docPrefix: 'docs', url: signedURL })\n const file = createFile()\n\n await invoke({ chunkLargeFiles: true, file })\n\n expect(blockBlobClientMock).toHaveBeenCalledWith(signedURL)\n expect(uploadDataMock).toHaveBeenCalledTimes(1)\n\n const [uploadedFile, options] = uploadDataMock.mock.calls[0]!\n expect(uploadedFile).toBe(file)\n expect(options.blockSize).toBeGreaterThan(0)\n expect(options.concurrency).toBeGreaterThan(0)\n\n // Only the signed-URL request should hit fetch; no raw PUT to the blob URL.\n expect(fetchMock).toHaveBeenCalledTimes(1)\n })\n\n it('should pass the file content type to the blob headers', async () => {\n mockSignedURLResponse({ docPrefix: 'docs', url: signedURL })\n\n await invoke({ chunkLargeFiles: true })\n\n const [, options] = uploadDataMock.mock.calls[0]!\n expect(options.blobHTTPHeaders).toEqual({ blobContentType: 'image/png' })\n })\n\n it('should propagate errors from uploadData', async () => {\n mockSignedURLResponse({ docPrefix: 'docs', url: signedURL })\n uploadDataMock.mockRejectedValue(new Error('block upload failed'))\n\n await expect(invoke({ chunkLargeFiles: true })).rejects.toThrow('block upload failed')\n })\n })\n\n describe('chunkLargeFiles: false (single PUT, default/legacy)', () => {\n it('should upload via a single raw PUT with the BlockBlob header', async () => {\n const fetchMock = mockSignedURLResponse({ docPrefix: 'docs', url: signedURL })\n const file = createFile()\n\n await invoke({ chunkLargeFiles: false, file })\n\n // 1st fetch = signed-URL POST, 2nd = the raw PUT to the blob URL\n expect(fetchMock).toHaveBeenCalledTimes(2)\n const [putURL, putInit] = fetchMock.mock.calls[1]!\n expect(putURL).toBe(signedURL)\n expect(putInit.method).toBe('PUT')\n expect(putInit.body).toBe(file)\n expect(putInit.headers['x-ms-blob-type']).toBe('BlockBlob')\n expect(putInit.headers['Content-Type']).toBe('image/png')\n })\n\n it('should not use the Azure SDK', async () => {\n mockSignedURLResponse({ docPrefix: 'docs', url: signedURL })\n\n await invoke({ chunkLargeFiles: false })\n\n expect(blockBlobClientMock).not.toHaveBeenCalled()\n expect(uploadDataMock).not.toHaveBeenCalled()\n })\n })\n})\n"],"names":["beforeEach","describe","expect","it","vi","uploadDataMock","fn","blockBlobClientMock","uploadData","mock","BlockBlobClient","handleAzureUpload","serverURL","apiRoute","serverHandlerPath","signedURL","createFile","File","Uint8Array","type","mockSignedURLResponse","body","ok","fetchMock","mockResolvedValue","json","Promise","resolve","stubGlobal","invoke","overrides","chunkLargeFiles","collectionSlug","file","updateFilename","clearAllMocks","unstubAllGlobals","undefined","docPrefix","url","calledURL","init","calls","toBe","method","JSON","parse","toEqual","filename","mimeType","toHaveBeenCalledWith","not","toHaveBeenCalled","result","prefix","rejects","toThrow","toHaveBeenCalledTimes","uploadedFile","options","blockSize","toBeGreaterThan","concurrency","blobHTTPHeaders","blobContentType","mockRejectedValue","Error","putURL","putInit","headers"],"mappings":"AAAA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,SAAQ;AAE7D,MAAMC,iBAAiBD,GAAGE,EAAE;AAC5B,MAAMC,sBAAsBH,GAAGE,EAAE,CAAC;IAChC,OAAO;QAAEE,YAAYH;IAAe;AACtC;AAEAD,GAAGK,IAAI,CAAC,uBAAuB,IAAO,CAAA;QACpCC,iBAAiBH;IACnB,CAAA;AAEA,SAASI,iBAAiB,QAAQ,yBAAwB;AAE1D,MAAMC,YAAY;AAClB,MAAMC,WAAW;AACjB,MAAMC,oBAAoB;AAC1B,MAAMC,YAAY;AAElB,MAAMC,aAAa,IAAM,IAAIC,KAAK;QAAC,IAAIC,WAAW;YAAC;YAAG;YAAG;SAAE;KAAE,EAAE,YAAY;QAAEC,MAAM;IAAY;AAE/F,MAAMC,wBAAwB,CAACC,MAA+BC,KAAK,IAAI;IACrE,MAAMC,YAAYnB,GAAGE,EAAE,GAAGkB,iBAAiB,CAAC;QAC1CC,MAAM,IAAMC,QAAQC,OAAO,CAACN;QAC5BC;IACF;IACAlB,GAAGwB,UAAU,CAAC,SAASL;IACvB,OAAOA;AACT;AAEA,MAAMM,SAAS,CAACC,YAA8D,CAAC,CAAC,GAC9EnB,kBAAkB;QAChBE;QACAkB,iBAAiB;QACjBC,gBAAgB;QAChBC,MAAMjB;QACNF;QACAF;QACAsB,gBAAgB9B,GAAGE,EAAE;QACrB,GAAGwB,SAAS;IACd;AAEF7B,SAAS,qBAAqB;IAC5BD,WAAW;QACTI,GAAG+B,aAAa;QAChB/B,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ACjE,MAAMoB,YAAYH,sBAAsB;gBAAEkB,WAAW;gBAAQC,KAAKxB;YAAU;YAC5E,MAAMkB,OAAOjB;YAEb,MAAMa,OAAO;gBAAEE,iBAAiB;gBAAOE;YAAK;YAE5C,iEAAiE;YACjE/B,OAAOqB,WAAWkC,qBAAqB,CAAC;YACxC,MAAM,CAACU,QAAQC,QAAQ,GAAG7C,UAAUd,IAAI,CAACiC,KAAK,CAAC,EAAE;YACjDxC,OAAOiE,QAAQxB,IAAI,CAAC5B;YACpBb,OAAOkE,QAAQxB,MAAM,EAAED,IAAI,CAAC;YAC5BzC,OAAOkE,QAAQ/C,IAAI,EAAEsB,IAAI,CAACV;YAC1B/B,OAAOkE,QAAQC,OAAO,CAAC,iBAAiB,EAAE1B,IAAI,CAAC;YAC/CzC,OAAOkE,QAAQC,OAAO,CAAC,eAAe,EAAE1B,IAAI,CAAC;QAC/C;QAEAxC,GAAG,gCAAgC;YACjCiB,sBAAsB;gBAAEkB,WAAW;gBAAQC,KAAKxB;YAAU;YAE1D,MAAMc,OAAO;gBAAEE,iBAAiB;YAAM;YAEtC7B,OAAOK,qBAAqB4C,GAAG,CAACC,gBAAgB;YAChDlD,OAAOG,gBAAgB8C,GAAG,CAACC,gBAAgB;QAC7C;IACF;AACF"}
|
|
@@ -32,7 +32,7 @@ export const getGenerateSignedURLHandler = ({ access = defaultAccess, collection
|
|
|
32
32
|
blobName: fileKey,
|
|
33
33
|
containerName,
|
|
34
34
|
contentType: mimeType,
|
|
35
|
-
expiresOn: new Date(Date.now() +
|
|
35
|
+
expiresOn: new Date(Date.now() + 60 * 60 * 1000),
|
|
36
36
|
permissions: BlobSASPermissions.parse('w'),
|
|
37
37
|
startsOn: new Date()
|
|
38
38
|
}, getStorageClient().credential);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generateSignedURL.ts"],"sourcesContent":["import type { ContainerClient, StorageSharedKeyCredential } from '@azure/storage-blob'\nimport type { ClientUploadsAccess } from '@payloadcms/plugin-cloud-storage/types'\nimport type { PayloadHandler } from 'payload'\n\nimport { BlobSASPermissions, generateBlobSASQueryParameters } from '@azure/storage-blob'\nimport { resolveSignedURLKey } from '@payloadcms/plugin-cloud-storage/utilities'\nimport { APIError, Forbidden } from 'payload'\n\nimport type { AzureStorageOptions } from './index.js'\n\ninterface Args {\n access?: ClientUploadsAccess\n collections: AzureStorageOptions['collections']\n containerName: string\n getStorageClient: () => ContainerClient\n useCompositePrefixes?: boolean\n}\n\nconst defaultAccess: Args['access'] = ({ req }) => !!req.user\n\nexport const getGenerateSignedURLHandler = ({\n access = defaultAccess,\n collections,\n containerName,\n getStorageClient,\n useCompositePrefixes = false,\n}: Args): PayloadHandler => {\n return async (req) => {\n if (!req.json) {\n throw new APIError('Unreachable')\n }\n\n const { collectionSlug, docPrefix, filename, mimeType } = (await req.json()) as {\n collectionSlug: string\n docPrefix?: string\n filename: string\n mimeType: string\n }\n\n const collectionStorageConfig = collections[collectionSlug]\n if (!collectionStorageConfig) {\n throw new APIError(`Collection ${collectionSlug} was not found in Azure storage options`)\n }\n\n const collectionPrefix =\n (typeof collectionStorageConfig === 'object' && collectionStorageConfig.prefix) || ''\n\n if (!(await access({ collectionSlug, req }))) {\n throw new Forbidden()\n }\n\n const { fileKey, sanitizedDocPrefix, sanitizedFilename } = await resolveSignedURLKey({\n collectionPrefix,\n collectionSlug,\n docPrefix,\n filename,\n req,\n useCompositePrefixes,\n })\n\n const blobClient = getStorageClient().getBlobClient(fileKey)\n\n const sasToken = generateBlobSASQueryParameters(\n {\n blobName: fileKey,\n containerName,\n contentType: mimeType,\n expiresOn: new Date(Date.now() +
|
|
1
|
+
{"version":3,"sources":["../src/generateSignedURL.ts"],"sourcesContent":["import type { ContainerClient, StorageSharedKeyCredential } from '@azure/storage-blob'\nimport type { ClientUploadsAccess } from '@payloadcms/plugin-cloud-storage/types'\nimport type { PayloadHandler } from 'payload'\n\nimport { BlobSASPermissions, generateBlobSASQueryParameters } from '@azure/storage-blob'\nimport { resolveSignedURLKey } from '@payloadcms/plugin-cloud-storage/utilities'\nimport { APIError, Forbidden } from 'payload'\n\nimport type { AzureStorageOptions } from './index.js'\n\ninterface Args {\n access?: ClientUploadsAccess\n collections: AzureStorageOptions['collections']\n containerName: string\n getStorageClient: () => ContainerClient\n useCompositePrefixes?: boolean\n}\n\nconst defaultAccess: Args['access'] = ({ req }) => !!req.user\n\nexport const getGenerateSignedURLHandler = ({\n access = defaultAccess,\n collections,\n containerName,\n getStorageClient,\n useCompositePrefixes = false,\n}: Args): PayloadHandler => {\n return async (req) => {\n if (!req.json) {\n throw new APIError('Unreachable')\n }\n\n const { collectionSlug, docPrefix, filename, mimeType } = (await req.json()) as {\n collectionSlug: string\n docPrefix?: string\n filename: string\n mimeType: string\n }\n\n const collectionStorageConfig = collections[collectionSlug]\n if (!collectionStorageConfig) {\n throw new APIError(`Collection ${collectionSlug} was not found in Azure storage options`)\n }\n\n const collectionPrefix =\n (typeof collectionStorageConfig === 'object' && collectionStorageConfig.prefix) || ''\n\n if (!(await access({ collectionSlug, req }))) {\n throw new Forbidden()\n }\n\n const { fileKey, sanitizedDocPrefix, sanitizedFilename } = await resolveSignedURLKey({\n collectionPrefix,\n collectionSlug,\n docPrefix,\n filename,\n req,\n useCompositePrefixes,\n })\n\n const blobClient = getStorageClient().getBlobClient(fileKey)\n\n const sasToken = generateBlobSASQueryParameters(\n {\n blobName: fileKey,\n containerName,\n contentType: mimeType,\n expiresOn: new Date(Date.now() + 60 * 60 * 1000),\n permissions: BlobSASPermissions.parse('w'),\n startsOn: new Date(),\n },\n getStorageClient().credential as StorageSharedKeyCredential,\n )\n\n return Response.json({\n docPrefix: sanitizedDocPrefix,\n filename: sanitizedFilename,\n url: `${blobClient.url}?${sasToken.toString()}`,\n })\n }\n}\n"],"names":["BlobSASPermissions","generateBlobSASQueryParameters","resolveSignedURLKey","APIError","Forbidden","defaultAccess","req","user","getGenerateSignedURLHandler","access","collections","containerName","getStorageClient","useCompositePrefixes","json","collectionSlug","docPrefix","filename","mimeType","collectionStorageConfig","collectionPrefix","prefix","fileKey","sanitizedDocPrefix","sanitizedFilename","blobClient","getBlobClient","sasToken","blobName","contentType","expiresOn","Date","now","permissions","parse","startsOn","credential","Response","url","toString"],"mappings":"AAIA,SAASA,kBAAkB,EAAEC,8BAA8B,QAAQ,sBAAqB;AACxF,SAASC,mBAAmB,QAAQ,6CAA4C;AAChF,SAASC,QAAQ,EAAEC,SAAS,QAAQ,UAAS;AAY7C,MAAMC,gBAAgC,CAAC,EAAEC,GAAG,EAAE,GAAK,CAAC,CAACA,IAAIC,IAAI;AAE7D,OAAO,MAAMC,8BAA8B,CAAC,EAC1CC,SAASJ,aAAa,EACtBK,WAAW,EACXC,aAAa,EACbC,gBAAgB,EAChBC,uBAAuB,KAAK,EACvB;IACL,OAAO,OAAOP;QACZ,IAAI,CAACA,IAAIQ,IAAI,EAAE;YACb,MAAM,IAAIX,SAAS;QACrB;QAEA,MAAM,EAAEY,cAAc,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAI,MAAMZ,IAAIQ,IAAI;QAOzE,MAAMK,0BAA0BT,WAAW,CAACK,eAAe;QAC3D,IAAI,CAACI,yBAAyB;YAC5B,MAAM,IAAIhB,SAAS,CAAC,WAAW,EAAEY,eAAe,uCAAuC,CAAC;QAC1F;QAEA,MAAMK,mBACJ,AAAC,OAAOD,4BAA4B,YAAYA,wBAAwBE,MAAM,IAAK;QAErF,IAAI,CAAE,MAAMZ,OAAO;YAAEM;YAAgBT;QAAI,IAAK;YAC5C,MAAM,IAAIF;QACZ;QAEA,MAAM,EAAEkB,OAAO,EAAEC,kBAAkB,EAAEC,iBAAiB,EAAE,GAAG,MAAMtB,oBAAoB;YACnFkB;YACAL;YACAC;YACAC;YACAX;YACAO;QACF;QAEA,MAAMY,aAAab,mBAAmBc,aAAa,CAACJ;QAEpD,MAAMK,WAAW1B,+BACf;YACE2B,UAAUN;YACVX;YACAkB,aAAaX;YACbY,WAAW,IAAIC,KAAKA,KAAKC,GAAG,KAAK,KAAK,KAAK;YAC3CC,aAAajC,mBAAmBkC,KAAK,CAAC;YACtCC,UAAU,IAAIJ;QAChB,GACAnB,mBAAmBwB,UAAU;QAG/B,OAAOC,SAASvB,IAAI,CAAC;YACnBE,WAAWO;YACXN,UAAUO;YACVc,KAAK,GAAGb,WAAWa,GAAG,CAAC,CAAC,EAAEX,SAASY,QAAQ,IAAI;QACjD;IACF;AACF,EAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ClientUploadsAccess, CollectionOptions } from '@payloadcms/plugin-cloud-storage/types';
|
|
2
2
|
import type { Plugin, UploadCollectionSlug } from 'payload';
|
|
3
3
|
import { getStorageClient as getStorageClientFunc } from './utils/getStorageClient.js';
|
|
4
|
+
export type AzureClientUploadsConfig = {
|
|
5
|
+
access?: ClientUploadsAccess;
|
|
6
|
+
/**
|
|
7
|
+
* Upload large files in blocks via the Azure Blob SDK, lifting the ~5GB
|
|
8
|
+
* single-request limit. Requires broader CORS on the storage account
|
|
9
|
+
* (the `OPTIONS`/`PUT` methods and `x-ms-*` headers).
|
|
10
|
+
*
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
chunkLargeFiles?: boolean;
|
|
14
|
+
} | boolean;
|
|
4
15
|
export type AzureStorageOptions = {
|
|
5
16
|
/**
|
|
6
17
|
* Whether or not to allow the container to be created if it does not exist
|
|
@@ -31,8 +42,15 @@ export type AzureStorageOptions = {
|
|
|
31
42
|
clientCacheKey?: string;
|
|
32
43
|
/**
|
|
33
44
|
* Do uploads directly on the client to bypass limits on Vercel. You must allow CORS PUT method to your website.
|
|
45
|
+
*
|
|
46
|
+
* Set `chunkLargeFiles: true` to upload through the Azure Blob SDK, which splits
|
|
47
|
+
* large files into blocks and lifts the ~5GB single-request limit. The SDK sends
|
|
48
|
+
* additional `x-ms-*` headers, so your storage account's CORS rules must allow the
|
|
49
|
+
* `OPTIONS` and `PUT` methods and those headers (allowed headers `*`, or at minimum
|
|
50
|
+
* `x-ms-*,content-type,content-length`). Left off, uploads use a single request
|
|
51
|
+
* (the default) and are capped at ~5GB.
|
|
34
52
|
*/
|
|
35
|
-
clientUploads?:
|
|
53
|
+
clientUploads?: AzureClientUploadsConfig;
|
|
36
54
|
/**
|
|
37
55
|
* Collection options to apply the Azure Blob adapter to.
|
|
38
56
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAEnB,iBAAiB,EAClB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAU,MAAM,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAOnE,OAAO,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAEtF,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAA;IAE7B;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAE5B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAEnB,iBAAiB,EAClB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAU,MAAM,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAOnE,OAAO,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAEtF,MAAM,MAAM,wBAAwB,GAChC;IACE,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,GACD,OAAO,CAAA;AAEX,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAA;IAE7B;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAE5B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,wBAAwB,CAAA;IAExC;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAE7F;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;;;;;;;;OAYG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,CAAA;AAED,KAAK,kBAAkB,GAAG,CAAC,gBAAgB,EAAE,mBAAmB,KAAK,MAAM,CAAA;AAE3E,eAAO,MAAM,YAAY,EAAE,kBA+FxB,CAAA;AAEH,OAAO,EAAE,oBAAoB,IAAI,gBAAgB,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,9 @@ export const azureStorage = (azureStorageOptions)=>(incomingConfig)=>{
|
|
|
14
14
|
collections: azureStorageOptions.collections,
|
|
15
15
|
config: incomingConfig,
|
|
16
16
|
enabled: !isPluginDisabled && Boolean(azureStorageOptions.clientUploads),
|
|
17
|
+
extraClientHandlerProps: ()=>({
|
|
18
|
+
chunkLargeFiles: typeof azureStorageOptions.clientUploads === 'object' ? Boolean(azureStorageOptions.clientUploads.chunkLargeFiles) : false
|
|
19
|
+
}),
|
|
17
20
|
serverHandler: getGenerateSignedURLHandler({
|
|
18
21
|
access: typeof azureStorageOptions.clientUploads === 'object' ? azureStorageOptions.clientUploads.access : undefined,
|
|
19
22
|
collections: azureStorageOptions.collections,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type {\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type {\n ClientUploadsAccess,\n PluginOptions as CloudStoragePluginOptions,\n CollectionOptions,\n} from '@payloadcms/plugin-cloud-storage/types'\nimport type { Config, Plugin, UploadCollectionSlug } from 'payload'\n\nimport { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage'\nimport { initClientUploads } from '@payloadcms/plugin-cloud-storage/utilities'\n\nimport { createAzureAdapter } from './adapter.js'\nimport { getGenerateSignedURLHandler } from './generateSignedURL.js'\nimport { getStorageClient as getStorageClientFunc } from './utils/getStorageClient.js'\n\nexport type AzureClientUploadsConfig =\n | {\n access?: ClientUploadsAccess\n /**\n * Upload large files in blocks via the Azure Blob SDK, lifting the ~5GB\n * single-request limit. Requires broader CORS on the storage account\n * (the `OPTIONS`/`PUT` methods and `x-ms-*` headers).\n *\n * @default false\n */\n chunkLargeFiles?: boolean\n }\n | boolean\n\nexport type AzureStorageOptions = {\n /**\n * Whether or not to allow the container to be created if it does not exist\n *\n * @default false\n */\n allowContainerCreate: boolean\n\n /**\n * When enabled, fields (like the prefix field) will always be inserted into\n * the collection schema regardless of whether the plugin is enabled. This\n * ensures a consistent schema across all environments.\n *\n * This will be enabled by default in Payload v4.\n *\n * @default false\n */\n alwaysInsertFields?: boolean\n\n /**\n * Base URL for the Azure Blob storage account\n */\n baseURL: string\n\n /**\n * Optional cache key to identify the Azure Blob storage client instance.\n * If not provided, a default key will be used.\n *\n * @default `azure:containerName`\n */\n clientCacheKey?: string\n\n /**\n * Do uploads directly on the client to bypass limits on Vercel. You must allow CORS PUT method to your website.\n *\n * Set `chunkLargeFiles: true` to upload through the Azure Blob SDK, which splits\n * large files into blocks and lifts the ~5GB single-request limit. The SDK sends\n * additional `x-ms-*` headers, so your storage account's CORS rules must allow the\n * `OPTIONS` and `PUT` methods and those headers (allowed headers `*`, or at minimum\n * `x-ms-*,content-type,content-length`). Left off, uploads use a single request\n * (the default) and are capped at ~5GB.\n */\n clientUploads?: AzureClientUploadsConfig\n\n /**\n * Collection options to apply the Azure Blob adapter to.\n */\n collections: Partial<Record<UploadCollectionSlug, Omit<CollectionOptions, 'adapter'> | true>>\n\n /**\n * Azure Blob storage connection string\n */\n connectionString: string\n\n /**\n * Azure Blob storage container name\n */\n containerName: string\n\n /**\n * Whether or not to enable the plugin\n *\n * Default: true\n */\n enabled?: boolean\n /**\n * When true, the collection-level prefix and document-level prefix are combined\n * (compositional). When false (default), document prefix overrides collection\n * prefix entirely.\n *\n * Example:\n * - collection prefix: `collection-prefix/`\n * - document prefix: `document-prefix/`\n * - resulting prefix with useCompositePrefixes=true: `collection-prefix/document-prefix/`\n * - resulting prefix with useCompositePrefixes=false: `document-prefix/`\n *\n * @default false\n */\n useCompositePrefixes?: boolean\n}\n\ntype AzureStoragePlugin = (azureStorageArgs: AzureStorageOptions) => Plugin\n\nexport const azureStorage: AzureStoragePlugin =\n (azureStorageOptions: AzureStorageOptions) =>\n (incomingConfig: Config): Config => {\n const getStorageClient = () =>\n getStorageClientFunc({\n connectionString: azureStorageOptions.connectionString,\n containerName: azureStorageOptions.containerName,\n })\n\n const isPluginDisabled = azureStorageOptions.enabled === false\n\n initClientUploads({\n clientHandler: '@payloadcms/storage-azure/client#AzureClientUploadHandler',\n collections: azureStorageOptions.collections,\n config: incomingConfig,\n enabled: !isPluginDisabled && Boolean(azureStorageOptions.clientUploads),\n extraClientHandlerProps: () => ({\n chunkLargeFiles:\n typeof azureStorageOptions.clientUploads === 'object'\n ? Boolean(azureStorageOptions.clientUploads.chunkLargeFiles)\n : false,\n }),\n serverHandler: getGenerateSignedURLHandler({\n access:\n typeof azureStorageOptions.clientUploads === 'object'\n ? azureStorageOptions.clientUploads.access\n : undefined,\n collections: azureStorageOptions.collections,\n containerName: azureStorageOptions.containerName,\n getStorageClient,\n useCompositePrefixes: azureStorageOptions.useCompositePrefixes,\n }),\n serverHandlerPath: '/storage-azure-generate-signed-url',\n })\n\n if (isPluginDisabled) {\n return incomingConfig\n }\n\n const createContainerIfNotExists = () => {\n void getStorageClientFunc({\n connectionString: azureStorageOptions.connectionString,\n containerName: azureStorageOptions.containerName,\n }).createIfNotExists({\n access: 'blob',\n })\n }\n\n const adapter = createAzureAdapter({\n allowContainerCreate: azureStorageOptions.allowContainerCreate,\n baseURL: azureStorageOptions.baseURL,\n clientUploads: azureStorageOptions.clientUploads,\n containerName: azureStorageOptions.containerName,\n createContainerIfNotExists,\n getStorageClient,\n useCompositePrefixes: azureStorageOptions.useCompositePrefixes,\n })\n\n // Add adapter to each collection option object\n const collectionsWithAdapter: CloudStoragePluginOptions['collections'] = Object.entries(\n azureStorageOptions.collections,\n ).reduce(\n (acc, [slug, collOptions]) => ({\n ...acc,\n [slug]: {\n ...(collOptions === true ? {} : collOptions),\n adapter,\n },\n }),\n {} as Record<string, CollectionOptions>,\n )\n\n // Set disableLocalStorage: true for collections specified in the plugin options\n const config = {\n ...incomingConfig,\n collections: (incomingConfig.collections || []).map((collection) => {\n if (!collectionsWithAdapter[collection.slug]) {\n return collection\n }\n\n return {\n ...collection,\n upload: {\n ...(typeof collection.upload === 'object' ? collection.upload : {}),\n disableLocalStorage: true,\n },\n }\n }),\n }\n\n return cloudStoragePlugin({\n alwaysInsertFields: azureStorageOptions.alwaysInsertFields,\n collections: collectionsWithAdapter,\n useCompositePrefixes: azureStorageOptions.useCompositePrefixes,\n })(config)\n }\n\nexport { getStorageClientFunc as getStorageClient }\n"],"names":["cloudStoragePlugin","initClientUploads","createAzureAdapter","getGenerateSignedURLHandler","getStorageClient","getStorageClientFunc","azureStorage","azureStorageOptions","incomingConfig","connectionString","containerName","isPluginDisabled","enabled","clientHandler","collections","config","Boolean","clientUploads","extraClientHandlerProps","chunkLargeFiles","serverHandler","access","undefined","useCompositePrefixes","serverHandlerPath","createContainerIfNotExists","createIfNotExists","adapter","allowContainerCreate","baseURL","collectionsWithAdapter","Object","entries","reduce","acc","slug","collOptions","map","collection","upload","disableLocalStorage","alwaysInsertFields"],"mappings":"AAOA,SAASA,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,iBAAiB,QAAQ,6CAA4C;AAE9E,SAASC,kBAAkB,QAAQ,eAAc;AACjD,SAASC,2BAA2B,QAAQ,yBAAwB;AACpE,SAASC,oBAAoBC,oBAAoB,QAAQ,8BAA6B;AAmGtF,OAAO,MAAMC,eACX,CAACC,sBACD,CAACC;QACC,MAAMJ,mBAAmB,IACvBC,qBAAqB;gBACnBI,kBAAkBF,oBAAoBE,gBAAgB;gBACtDC,eAAeH,oBAAoBG,aAAa;YAClD;QAEF,MAAMC,mBAAmBJ,oBAAoBK,OAAO,KAAK;QAEzDX,kBAAkB;YAChBY,eAAe;YACfC,aAAaP,oBAAoBO,WAAW;YAC5CC,QAAQP;YACRI,SAAS,CAACD,oBAAoBK,QAAQT,oBAAoBU,aAAa;YACvEC,yBAAyB,IAAO,CAAA;oBAC9BC,iBACE,OAAOZ,oBAAoBU,aAAa,KAAK,WACzCD,QAAQT,oBAAoBU,aAAa,CAACE,eAAe,IACzD;gBACR,CAAA;YACAC,eAAejB,4BAA4B;gBACzCkB,QACE,OAAOd,oBAAoBU,aAAa,KAAK,WACzCV,oBAAoBU,aAAa,CAACI,MAAM,GACxCC;gBACNR,aAAaP,oBAAoBO,WAAW;gBAC5CJ,eAAeH,oBAAoBG,aAAa;gBAChDN;gBACAmB,sBAAsBhB,oBAAoBgB,oBAAoB;YAChE;YACAC,mBAAmB;QACrB;QAEA,IAAIb,kBAAkB;YACpB,OAAOH;QACT;QAEA,MAAMiB,6BAA6B;YACjC,KAAKpB,qBAAqB;gBACxBI,kBAAkBF,oBAAoBE,gBAAgB;gBACtDC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.
|
|
3
|
+
"version": "3.87.0",
|
|
4
4
|
"description": "Payload storage adapter for Azure Blob Storage",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@azure/abort-controller": "^1.1.0",
|
|
41
41
|
"@azure/storage-blob": "^12.11.0",
|
|
42
|
-
"@payloadcms/plugin-cloud-storage": "3.
|
|
42
|
+
"@payloadcms/plugin-cloud-storage": "3.87.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"payload": "3.
|
|
45
|
+
"payload": "3.87.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"payload": "3.
|
|
48
|
+
"payload": "3.87.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": "^18.20.2 || >=20.9.0"
|