@quatrain/storage-supabase 1.2.6 → 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.
|
@@ -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
|
}
|
package/package.json
CHANGED
|
@@ -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}`)
|