@directus/storage-driver-azure 11.0.2 → 11.1.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/dist/index.d.ts +10 -2
- package/dist/index.js +32 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TusDriver, ReadOptions, ChunkedUploadContext } from '@directus/storage';
|
|
2
2
|
import { Readable } from 'node:stream';
|
|
3
3
|
|
|
4
4
|
type DriverAzureConfig = {
|
|
@@ -7,8 +7,11 @@ type DriverAzureConfig = {
|
|
|
7
7
|
accountKey: string;
|
|
8
8
|
root?: string;
|
|
9
9
|
endpoint?: string;
|
|
10
|
+
tus?: {
|
|
11
|
+
chunkSize?: number;
|
|
12
|
+
};
|
|
10
13
|
};
|
|
11
|
-
declare class DriverAzure implements
|
|
14
|
+
declare class DriverAzure implements TusDriver {
|
|
12
15
|
private containerClient;
|
|
13
16
|
private signedCredentials;
|
|
14
17
|
private root;
|
|
@@ -25,6 +28,11 @@ declare class DriverAzure implements Driver {
|
|
|
25
28
|
move(src: string, dest: string): Promise<void>;
|
|
26
29
|
copy(src: string, dest: string): Promise<void>;
|
|
27
30
|
list(prefix?: string): AsyncGenerator<string, void, unknown>;
|
|
31
|
+
get tusExtensions(): string[];
|
|
32
|
+
createChunkedUpload(filepath: string, context: ChunkedUploadContext): Promise<ChunkedUploadContext>;
|
|
33
|
+
writeChunk(filepath: string, content: Readable, offset: number, _context: ChunkedUploadContext): Promise<number>;
|
|
34
|
+
finishChunkedUpload(_filepath: string, _context: ChunkedUploadContext): Promise<void>;
|
|
35
|
+
deleteChunkedUpload(filepath: string, _context: ChunkedUploadContext): Promise<void>;
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
export { DriverAzure, type DriverAzureConfig, DriverAzure as default };
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { BlobServiceClient, StorageSharedKeyCredential } from "@azure/storage-blob";
|
|
3
3
|
import { normalizePath } from "@directus/utils";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
+
import { finished } from "node:stream/promises";
|
|
6
|
+
var MAXIMUM_CHUNK_SIZE = 104857600;
|
|
5
7
|
var DriverAzure = class {
|
|
6
8
|
containerClient;
|
|
7
9
|
signedCredentials;
|
|
@@ -14,6 +16,9 @@ var DriverAzure = class {
|
|
|
14
16
|
);
|
|
15
17
|
this.containerClient = client.getContainerClient(config.containerName);
|
|
16
18
|
this.root = config.root ? normalizePath(config.root, { removeLeading: true }) : "";
|
|
19
|
+
if (config.tus?.chunkSize && config.tus.chunkSize > MAXIMUM_CHUNK_SIZE) {
|
|
20
|
+
throw new Error("Invalid chunkSize provided");
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
fullPath(filepath) {
|
|
19
24
|
return normalizePath(join(this.root, filepath));
|
|
@@ -63,6 +68,33 @@ var DriverAzure = class {
|
|
|
63
68
|
yield blob.name.substring(this.root.length);
|
|
64
69
|
}
|
|
65
70
|
}
|
|
71
|
+
get tusExtensions() {
|
|
72
|
+
return ["creation", "termination", "expiration"];
|
|
73
|
+
}
|
|
74
|
+
async createChunkedUpload(filepath, context) {
|
|
75
|
+
await this.containerClient.getAppendBlobClient(this.fullPath(filepath)).createIfNotExists();
|
|
76
|
+
return context;
|
|
77
|
+
}
|
|
78
|
+
async writeChunk(filepath, content, offset, _context) {
|
|
79
|
+
const client = this.containerClient.getAppendBlobClient(this.fullPath(filepath));
|
|
80
|
+
let bytesUploaded = offset || 0;
|
|
81
|
+
const chunks = [];
|
|
82
|
+
content.on("data", (chunk2) => {
|
|
83
|
+
bytesUploaded += chunk2.length;
|
|
84
|
+
chunks.push(chunk2);
|
|
85
|
+
});
|
|
86
|
+
await finished(content);
|
|
87
|
+
const chunk = Buffer.concat(chunks);
|
|
88
|
+
if (chunk.length > 0) {
|
|
89
|
+
await client.appendBlock(chunk, chunk.length);
|
|
90
|
+
}
|
|
91
|
+
return bytesUploaded;
|
|
92
|
+
}
|
|
93
|
+
async finishChunkedUpload(_filepath, _context) {
|
|
94
|
+
}
|
|
95
|
+
async deleteChunkedUpload(filepath, _context) {
|
|
96
|
+
await this.delete(filepath);
|
|
97
|
+
}
|
|
66
98
|
};
|
|
67
99
|
var src_default = DriverAzure;
|
|
68
100
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/storage-driver-azure",
|
|
3
|
-
"version": "11.0
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"description": "Azure file storage abstraction for `@directus/storage`",
|
|
5
5
|
"homepage": "https://directus.io",
|
|
6
6
|
"repository": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@azure/storage-blob": "12.25.0",
|
|
25
|
-
"@directus/
|
|
26
|
-
"@directus/
|
|
25
|
+
"@directus/storage": "11.0.1",
|
|
26
|
+
"@directus/utils": "12.0.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@ngneat/falso": "7.2.0",
|