@quatrain/storage-supabase 1.2.5 → 1.2.7
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.
|
@@ -117,7 +117,7 @@ class SupabaseStorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
117
117
|
const { error } = yield this._client
|
|
118
118
|
.from(file.bucket)
|
|
119
119
|
.upload(file.ref, new Blob([node_fs_1.default.readFileSync(stream)]), {
|
|
120
|
-
upsert:
|
|
120
|
+
upsert: storage_1.Storage.defaultUpsert,
|
|
121
121
|
contentType: file.contentType,
|
|
122
122
|
});
|
|
123
123
|
if (error !== null) {
|
|
@@ -134,7 +134,7 @@ class SupabaseStorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
134
134
|
.from(file.bucket)
|
|
135
135
|
.upload(file.ref, content, {
|
|
136
136
|
// cacheControl: '3600',
|
|
137
|
-
upsert:
|
|
137
|
+
upsert: storage_1.Storage.defaultUpsert,
|
|
138
138
|
contentType: file.contentType,
|
|
139
139
|
});
|
|
140
140
|
if (error !== null) {
|
|
@@ -204,9 +204,25 @@ class SupabaseStorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
204
204
|
// TODO: Le client Supabase JS ne supporte pas nativement l'override du ResponseCacheControl dans createSignedUrl.
|
|
205
205
|
// La variable publicCacheDuration / cacheControl n'est donc pas gérée correctement ici pour le moment.
|
|
206
206
|
// Voir si le SDK de Supabase permet de la supporter dans le futur.
|
|
207
|
+
let download = false;
|
|
208
|
+
if (action === 'download') {
|
|
209
|
+
download = true;
|
|
210
|
+
}
|
|
211
|
+
else if (extra.download !== undefined) {
|
|
212
|
+
download = extra.download;
|
|
213
|
+
}
|
|
214
|
+
else if (extra.responseDisposition && extra.responseDisposition.includes('attachment')) {
|
|
215
|
+
const match = extra.responseDisposition.match(/filename="([^"]+)"/);
|
|
216
|
+
if (match && match[1]) {
|
|
217
|
+
download = match[1];
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
download = true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
207
223
|
const { data, error } = yield this._client
|
|
208
224
|
.from(file.bucket)
|
|
209
|
-
.createSignedUrl(file.ref, expiresIn, { download
|
|
225
|
+
.createSignedUrl(file.ref, expiresIn, { download });
|
|
210
226
|
if (error !== null) {
|
|
211
227
|
throw new Error(`Unable to get signed url: ${error}`);
|
|
212
228
|
}
|
|
@@ -306,7 +322,7 @@ class SupabaseStorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
306
322
|
return __awaiter(this, arguments, void 0, function* (file, _expiresIn = 7200) {
|
|
307
323
|
const { data, error } = yield this._client
|
|
308
324
|
.from(file.bucket)
|
|
309
|
-
.createSignedUploadUrl(file.ref, { upsert:
|
|
325
|
+
.createSignedUploadUrl(file.ref, { upsert: storage_1.Storage.defaultUpsert });
|
|
310
326
|
if (error !== null) {
|
|
311
327
|
throw new Error(`Unable to get signed upload url: ${error}`);
|
|
312
328
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/storage-supabase",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "Storage adapter for Supabase Storage",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"typescript": "^5.1.5"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@quatrain/core": "^1.2.
|
|
35
|
-
"@quatrain/storage": "^1.2.
|
|
34
|
+
"@quatrain/core": "^1.2.16",
|
|
35
|
+
"@quatrain/storage": "^1.2.12",
|
|
36
36
|
"@supabase/storage-js": "^2.7.2",
|
|
37
|
-
"@supabase/supabase-js": "^2.
|
|
37
|
+
"@supabase/supabase-js": "^2.108.2"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"test-ci": "jest --runInBand",
|
|
@@ -120,7 +120,7 @@ export class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
|
120
120
|
const { error } = await this._client
|
|
121
121
|
.from(file.bucket)
|
|
122
122
|
.upload(file.ref, new Blob([fs.readFileSync(stream)]), {
|
|
123
|
-
upsert:
|
|
123
|
+
upsert: Storage.defaultUpsert,
|
|
124
124
|
contentType: file.contentType,
|
|
125
125
|
})
|
|
126
126
|
if (error !== null) {
|
|
@@ -136,7 +136,7 @@ export class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
|
136
136
|
.from(file.bucket)
|
|
137
137
|
.upload(file.ref, content, {
|
|
138
138
|
// cacheControl: '3600',
|
|
139
|
-
upsert:
|
|
139
|
+
upsert: Storage.defaultUpsert,
|
|
140
140
|
contentType: file.contentType,
|
|
141
141
|
})
|
|
142
142
|
if (error !== null) {
|
|
@@ -214,9 +214,23 @@ export class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
|
214
214
|
// La variable publicCacheDuration / cacheControl n'est donc pas gérée correctement ici pour le moment.
|
|
215
215
|
// Voir si le SDK de Supabase permet de la supporter dans le futur.
|
|
216
216
|
|
|
217
|
+
let download: boolean | string = false
|
|
218
|
+
if (action === 'download') {
|
|
219
|
+
download = true
|
|
220
|
+
} else if (extra.download !== undefined) {
|
|
221
|
+
download = extra.download
|
|
222
|
+
} else if (extra.responseDisposition && extra.responseDisposition.includes('attachment')) {
|
|
223
|
+
const match = extra.responseDisposition.match(/filename="([^"]+)"/)
|
|
224
|
+
if (match && match[1]) {
|
|
225
|
+
download = match[1]
|
|
226
|
+
} else {
|
|
227
|
+
download = true
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
217
231
|
const { data, error } = await this._client
|
|
218
232
|
.from(file.bucket)
|
|
219
|
-
.createSignedUrl(file.ref, expiresIn, { download
|
|
233
|
+
.createSignedUrl(file.ref, expiresIn, { download })
|
|
220
234
|
|
|
221
235
|
if (error !== null) {
|
|
222
236
|
throw new Error(`Unable to get signed url: ${error}`)
|
|
@@ -330,7 +344,7 @@ export class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
|
330
344
|
): Promise<FileResponseLinkType> {
|
|
331
345
|
const { data, error } = await this._client
|
|
332
346
|
.from(file.bucket)
|
|
333
|
-
.createSignedUploadUrl(file.ref, { upsert:
|
|
347
|
+
.createSignedUploadUrl(file.ref, { upsert: Storage.defaultUpsert })
|
|
334
348
|
|
|
335
349
|
if (error !== null) {
|
|
336
350
|
throw new Error(`Unable to get signed upload url: ${error}`)
|