@supabase/storage-js 1.7.3 → 1.8.0-next.3
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 +11 -1
- package/dist/main/index.d.ts +1 -0
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +6 -1
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/StorageBucketApi.d.ts +31 -12
- package/dist/main/lib/StorageBucketApi.d.ts.map +1 -1
- package/dist/main/lib/StorageBucketApi.js +33 -14
- package/dist/main/lib/StorageBucketApi.js.map +1 -1
- package/dist/main/lib/StorageFileApi.d.ts +50 -29
- package/dist/main/lib/StorageFileApi.d.ts.map +1 -1
- package/dist/main/lib/StorageFileApi.js +88 -38
- package/dist/main/lib/StorageFileApi.js.map +1 -1
- package/dist/main/lib/errors.d.ts +19 -0
- package/dist/main/lib/errors.d.ts.map +1 -0
- package/dist/main/lib/errors.js +39 -0
- package/dist/main/lib/errors.js.map +1 -0
- package/dist/main/lib/fetch.d.ts.map +1 -1
- package/dist/main/lib/fetch.js +13 -11
- package/dist/main/lib/fetch.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +6 -0
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +15 -3
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/index.js +5 -1
- package/dist/main/lib/index.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/module/index.d.ts +1 -0
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/StorageBucketApi.d.ts +31 -12
- package/dist/module/lib/StorageBucketApi.d.ts.map +1 -1
- package/dist/module/lib/StorageBucketApi.js +26 -7
- package/dist/module/lib/StorageBucketApi.js.map +1 -1
- package/dist/module/lib/StorageFileApi.d.ts +50 -29
- package/dist/module/lib/StorageFileApi.d.ts.map +1 -1
- package/dist/module/lib/StorageFileApi.js +80 -30
- package/dist/module/lib/StorageFileApi.js.map +1 -1
- package/dist/module/lib/errors.d.ts +19 -0
- package/dist/module/lib/errors.d.ts.map +1 -0
- package/dist/module/lib/errors.js +32 -0
- package/dist/module/lib/errors.js.map +1 -0
- package/dist/module/lib/fetch.d.ts.map +1 -1
- package/dist/module/lib/fetch.js +13 -11
- package/dist/module/lib/fetch.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +6 -0
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +6 -0
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/lib/StorageBucketApi.ts +94 -13
- package/src/lib/StorageFileApi.ts +195 -53
- package/src/lib/errors.ts +40 -0
- package/src/lib/fetch.ts +13 -10
- package/src/lib/helpers.ts +8 -0
- package/src/lib/version.ts +1 -1
package/README.md
CHANGED
|
@@ -82,6 +82,16 @@ const storageClient = new SupabaseStorageClient(STORAGE_URL, {
|
|
|
82
82
|
const { data, error } = await storageClient.from('bucket').upload('path/to/file', fileBody)
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
> Note:
|
|
86
|
+
> The path in `data.Key` is prefixed by the bucket ID and is not the value which should be passed to the `download` method in order to fetch the file.
|
|
87
|
+
> To fetch the file via the `download` method, use `data.path` and `data.bucketId` as follows:
|
|
88
|
+
>
|
|
89
|
+
> ```javascript
|
|
90
|
+
> const { data, error } = await storageClient.from('bucket').upload('/folder/file.txt', fileBody)
|
|
91
|
+
> // check for errors
|
|
92
|
+
> const { data2, error2 } = await storageClient.from(data.bucketId).download(data.path)
|
|
93
|
+
> ```
|
|
94
|
+
|
|
85
95
|
> Note: The `upload` method also accepts a map of optional parameters. For a complete list see the [Supabase API reference](https://supabase.com/docs/reference/javascript/storage-from-upload).
|
|
86
96
|
|
|
87
97
|
- Download a file from an exisiting bucket:
|
|
@@ -128,7 +138,7 @@ const storageClient = new SupabaseStorageClient(STORAGE_URL, {
|
|
|
128
138
|
|
|
129
139
|
```js
|
|
130
140
|
const expireIn = 60
|
|
131
|
-
|
|
141
|
+
|
|
132
142
|
const { data, error } = await storageClient
|
|
133
143
|
.from('bucket')
|
|
134
144
|
.createSignedUrl('path/to/file', expireIn)
|
package/dist/main/index.d.ts
CHANGED
package/dist/main/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,IAAI,aAAa,EAC9B,aAAa,IAAI,qBAAqB,GACvC,MAAM,iBAAiB,CAAA;AACxB,cAAc,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,IAAI,aAAa,EAC9B,aAAa,IAAI,qBAAqB,GACvC,MAAM,iBAAiB,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
|
package/dist/main/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -15,4 +19,5 @@ var StorageClient_1 = require("./StorageClient");
|
|
|
15
19
|
Object.defineProperty(exports, "StorageClient", { enumerable: true, get: function () { return StorageClient_1.StorageClient; } });
|
|
16
20
|
Object.defineProperty(exports, "SupabaseStorageClient", { enumerable: true, get: function () { return StorageClient_1.StorageClient; } });
|
|
17
21
|
__exportStar(require("./lib/types"), exports);
|
|
22
|
+
__exportStar(require("./lib/errors"), exports);
|
|
18
23
|
//# sourceMappingURL=index.js.map
|
package/dist/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAGwB;AAFtB,8GAAA,aAAa,OAAiB;AAC9B,sHAAA,aAAa,OAAyB;AAExC,8CAA2B;AAC3B,+CAA4B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StorageError } from './errors';
|
|
1
2
|
import { Fetch } from './fetch';
|
|
2
3
|
import { Bucket } from './types';
|
|
3
4
|
export declare class StorageBucketApi {
|
|
@@ -13,8 +14,11 @@ export declare class StorageBucketApi {
|
|
|
13
14
|
* Retrieves the details of all Storage buckets within an existing project.
|
|
14
15
|
*/
|
|
15
16
|
listBuckets(): Promise<{
|
|
16
|
-
data: Bucket[]
|
|
17
|
-
error:
|
|
17
|
+
data: Bucket[];
|
|
18
|
+
error: null;
|
|
19
|
+
} | {
|
|
20
|
+
data: null;
|
|
21
|
+
error: StorageError;
|
|
18
22
|
}>;
|
|
19
23
|
/**
|
|
20
24
|
* Retrieves the details of an existing Storage bucket.
|
|
@@ -22,8 +26,11 @@ export declare class StorageBucketApi {
|
|
|
22
26
|
* @param id The unique identifier of the bucket you would like to retrieve.
|
|
23
27
|
*/
|
|
24
28
|
getBucket(id: string): Promise<{
|
|
25
|
-
data: Bucket
|
|
26
|
-
error:
|
|
29
|
+
data: Bucket;
|
|
30
|
+
error: null;
|
|
31
|
+
} | {
|
|
32
|
+
data: null;
|
|
33
|
+
error: StorageError;
|
|
27
34
|
}>;
|
|
28
35
|
/**
|
|
29
36
|
* Creates a new Storage bucket
|
|
@@ -34,8 +41,11 @@ export declare class StorageBucketApi {
|
|
|
34
41
|
createBucket(id: string, options?: {
|
|
35
42
|
public: boolean;
|
|
36
43
|
}): Promise<{
|
|
37
|
-
data:
|
|
38
|
-
error:
|
|
44
|
+
data: Pick<Bucket, 'name'>;
|
|
45
|
+
error: null;
|
|
46
|
+
} | {
|
|
47
|
+
data: null;
|
|
48
|
+
error: StorageError;
|
|
39
49
|
}>;
|
|
40
50
|
/**
|
|
41
51
|
* Updates a new Storage bucket
|
|
@@ -47,8 +57,11 @@ export declare class StorageBucketApi {
|
|
|
47
57
|
}): Promise<{
|
|
48
58
|
data: {
|
|
49
59
|
message: string;
|
|
50
|
-
}
|
|
51
|
-
error:
|
|
60
|
+
};
|
|
61
|
+
error: null;
|
|
62
|
+
} | {
|
|
63
|
+
data: null;
|
|
64
|
+
error: StorageError;
|
|
52
65
|
}>;
|
|
53
66
|
/**
|
|
54
67
|
* Removes all objects inside a single bucket.
|
|
@@ -58,8 +71,11 @@ export declare class StorageBucketApi {
|
|
|
58
71
|
emptyBucket(id: string): Promise<{
|
|
59
72
|
data: {
|
|
60
73
|
message: string;
|
|
61
|
-
}
|
|
62
|
-
error:
|
|
74
|
+
};
|
|
75
|
+
error: null;
|
|
76
|
+
} | {
|
|
77
|
+
data: null;
|
|
78
|
+
error: StorageError;
|
|
63
79
|
}>;
|
|
64
80
|
/**
|
|
65
81
|
* Deletes an existing bucket. A bucket can't be deleted with existing objects inside it.
|
|
@@ -70,8 +86,11 @@ export declare class StorageBucketApi {
|
|
|
70
86
|
deleteBucket(id: string): Promise<{
|
|
71
87
|
data: {
|
|
72
88
|
message: string;
|
|
73
|
-
}
|
|
74
|
-
error:
|
|
89
|
+
};
|
|
90
|
+
error: null;
|
|
91
|
+
} | {
|
|
92
|
+
data: null;
|
|
93
|
+
error: StorageError;
|
|
75
94
|
}>;
|
|
76
95
|
}
|
|
77
96
|
//# sourceMappingURL=StorageBucketApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageBucketApi.d.ts","sourceRoot":"","sources":["../../../src/lib/StorageBucketApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAA0B,MAAM,SAAS,CAAA;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,qBAAa,gBAAgB;IAC3B,SAAS,CAAC,GAAG,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IAC5C,SAAS,CAAC,KAAK,EAAE,KAAK,CAAA;gBAEV,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,EAAE,KAAK,CAAC,EAAE,KAAK;IAM/E;;OAEG;IACG,WAAW,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"StorageBucketApi.d.ts","sourceRoot":"","sources":["../../../src/lib/StorageBucketApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,YAAY,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,EAAE,KAAK,EAA0B,MAAM,SAAS,CAAA;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,qBAAa,gBAAgB;IAC3B,SAAS,CAAC,GAAG,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IAC5C,SAAS,CAAC,KAAK,EAAE,KAAK,CAAA;gBAEV,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO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A;KACpB,CACJ;IAkBD;;;;;OAKG;IACG,YAAY,CAChB,EAAE,EAAE,MAAM,GACT,OAAO,CACN;QACE,IAAI,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAA;QACzB,KAAK,EAAE,IAAI,CAAA;KACZ,GACD;QACE,IAAI,EAAE,IAAI,CAAA;QACV,KAAK,EAAE,YAAY,CAAA;KACpB,CACJ;CAiBF"}
|
|
@@ -11,13 +11,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.StorageBucketApi = void 0;
|
|
13
13
|
const constants_1 = require("./constants");
|
|
14
|
+
const errors_1 = require("./errors");
|
|
14
15
|
const fetch_1 = require("./fetch");
|
|
15
16
|
const helpers_1 = require("./helpers");
|
|
16
17
|
class StorageBucketApi {
|
|
17
18
|
constructor(url, headers = {}, fetch) {
|
|
18
19
|
this.url = url;
|
|
19
20
|
this.headers = Object.assign(Object.assign({}, constants_1.DEFAULT_HEADERS), headers);
|
|
20
|
-
this.fetch = helpers_1.resolveFetch(fetch);
|
|
21
|
+
this.fetch = (0, helpers_1.resolveFetch)(fetch);
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* Retrieves the details of all Storage buckets within an existing project.
|
|
@@ -25,11 +26,14 @@ class StorageBucketApi {
|
|
|
25
26
|
listBuckets() {
|
|
26
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
28
|
try {
|
|
28
|
-
const data = yield fetch_1.get(this.fetch, `${this.url}/bucket`, { headers: this.headers });
|
|
29
|
+
const data = yield (0, fetch_1.get)(this.fetch, `${this.url}/bucket`, { headers: this.headers });
|
|
29
30
|
return { data, error: null };
|
|
30
31
|
}
|
|
31
32
|
catch (error) {
|
|
32
|
-
|
|
33
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
34
|
+
return { data: null, error };
|
|
35
|
+
}
|
|
36
|
+
throw error;
|
|
33
37
|
}
|
|
34
38
|
});
|
|
35
39
|
}
|
|
@@ -41,11 +45,14 @@ class StorageBucketApi {
|
|
|
41
45
|
getBucket(id) {
|
|
42
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
47
|
try {
|
|
44
|
-
const data = yield fetch_1.get(this.fetch, `${this.url}/bucket/${id}`, { headers: this.headers });
|
|
48
|
+
const data = yield (0, fetch_1.get)(this.fetch, `${this.url}/bucket/${id}`, { headers: this.headers });
|
|
45
49
|
return { data, error: null };
|
|
46
50
|
}
|
|
47
51
|
catch (error) {
|
|
48
|
-
|
|
52
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
53
|
+
return { data: null, error };
|
|
54
|
+
}
|
|
55
|
+
throw error;
|
|
49
56
|
}
|
|
50
57
|
});
|
|
51
58
|
}
|
|
@@ -58,11 +65,14 @@ class StorageBucketApi {
|
|
|
58
65
|
createBucket(id, options = { public: false }) {
|
|
59
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
67
|
try {
|
|
61
|
-
const data = yield fetch_1.post(this.fetch, `${this.url}/bucket`, { id, name: id, public: options.public }, { headers: this.headers });
|
|
62
|
-
return { data
|
|
68
|
+
const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/bucket`, { id, name: id, public: options.public }, { headers: this.headers });
|
|
69
|
+
return { data, error: null };
|
|
63
70
|
}
|
|
64
71
|
catch (error) {
|
|
65
|
-
|
|
72
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
73
|
+
return { data: null, error };
|
|
74
|
+
}
|
|
75
|
+
throw error;
|
|
66
76
|
}
|
|
67
77
|
});
|
|
68
78
|
}
|
|
@@ -74,11 +84,14 @@ class StorageBucketApi {
|
|
|
74
84
|
updateBucket(id, options) {
|
|
75
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
86
|
try {
|
|
77
|
-
const data = yield fetch_1.put(this.fetch, `${this.url}/bucket/${id}`, { id, name: id, public: options.public }, { headers: this.headers });
|
|
87
|
+
const data = yield (0, fetch_1.put)(this.fetch, `${this.url}/bucket/${id}`, { id, name: id, public: options.public }, { headers: this.headers });
|
|
78
88
|
return { data, error: null };
|
|
79
89
|
}
|
|
80
90
|
catch (error) {
|
|
81
|
-
|
|
91
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
92
|
+
return { data: null, error };
|
|
93
|
+
}
|
|
94
|
+
throw error;
|
|
82
95
|
}
|
|
83
96
|
});
|
|
84
97
|
}
|
|
@@ -90,11 +103,14 @@ class StorageBucketApi {
|
|
|
90
103
|
emptyBucket(id) {
|
|
91
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
105
|
try {
|
|
93
|
-
const data = yield fetch_1.post(this.fetch, `${this.url}/bucket/${id}/empty`, {}, { headers: this.headers });
|
|
106
|
+
const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/bucket/${id}/empty`, {}, { headers: this.headers });
|
|
94
107
|
return { data, error: null };
|
|
95
108
|
}
|
|
96
109
|
catch (error) {
|
|
97
|
-
|
|
110
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
111
|
+
return { data: null, error };
|
|
112
|
+
}
|
|
113
|
+
throw error;
|
|
98
114
|
}
|
|
99
115
|
});
|
|
100
116
|
}
|
|
@@ -107,11 +123,14 @@ class StorageBucketApi {
|
|
|
107
123
|
deleteBucket(id) {
|
|
108
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
125
|
try {
|
|
110
|
-
const data = yield fetch_1.remove(this.fetch, `${this.url}/bucket/${id}`, {}, { headers: this.headers });
|
|
126
|
+
const data = yield (0, fetch_1.remove)(this.fetch, `${this.url}/bucket/${id}`, {}, { headers: this.headers });
|
|
111
127
|
return { data, error: null };
|
|
112
128
|
}
|
|
113
129
|
catch (error) {
|
|
114
|
-
|
|
130
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
131
|
+
return { data: null, error };
|
|
132
|
+
}
|
|
133
|
+
throw error;
|
|
115
134
|
}
|
|
116
135
|
});
|
|
117
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageBucketApi.js","sourceRoot":"","sources":["../../../src/lib/StorageBucketApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6C;AAC7C,mCAAuD;AACvD,uCAAwC;AAGxC,MAAa,gBAAgB;IAK3B,YAAY,GAAW,EAAE,UAAqC,EAAE,EAAE,KAAa;QAC7E,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,OAAO,mCAAQ,2BAAe,GAAK,OAAO,CAAE,CAAA;QACjD,IAAI,CAAC,KAAK,GAAG,sBAAY,
|
|
1
|
+
{"version":3,"file":"StorageBucketApi.js","sourceRoot":"","sources":["../../../src/lib/StorageBucketApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6C;AAC7C,qCAAuD;AACvD,mCAAuD;AACvD,uCAAwC;AAGxC,MAAa,gBAAgB;IAK3B,YAAY,GAAW,EAAE,UAAqC,EAAE,EAAE,KAAa;QAC7E,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,OAAO,mCAAQ,2BAAe,GAAK,OAAO,CAAE,CAAA;QACjD,IAAI,CAAC,KAAK,GAAG,IAAA,sBAAY,EAAC,KAAK,CAAC,CAAA;IAClC,CAAC;IAED;;OAEG;IACG,WAAW;;YAUf,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAA,WAAG,EAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;gBACnF,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;aAC7B;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,IAAA,uBAAc,EAAC,KAAK,CAAC,EAAE;oBACzB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;iBAC7B;gBAED,MAAM,KAA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AE,IAAI,EAAE,CAAA;aAC7B;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,IAAA,uBAAc,EAAC,KAAK,CAAC,EAAE;oBACzB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;iBAC7B;gBAED,MAAM,KAAK,CAAA;aACZ;QACH,CAAC;KAAA;CACF;AA5MD,4CA4MC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { StorageError } from './errors';
|
|
2
3
|
import { Fetch, FetchParameters } from './fetch';
|
|
3
4
|
import { FileObject, FileOptions, SearchOptions } from './types';
|
|
4
5
|
export declare class StorageFileApi {
|
|
@@ -35,9 +36,12 @@ export declare class StorageFileApi {
|
|
|
35
36
|
*/
|
|
36
37
|
upload(path: string, fileBody: ArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | NodeJS.ReadableStream | ReadableStream<Uint8Array> | URLSearchParams | string, fileOptions?: FileOptions): Promise<{
|
|
37
38
|
data: {
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
error:
|
|
39
|
+
path: string;
|
|
40
|
+
};
|
|
41
|
+
error: null;
|
|
42
|
+
} | {
|
|
43
|
+
data: null;
|
|
44
|
+
error: StorageError;
|
|
41
45
|
}>;
|
|
42
46
|
/**
|
|
43
47
|
* Replaces an existing file at the specified path with a new one.
|
|
@@ -51,9 +55,12 @@ export declare class StorageFileApi {
|
|
|
51
55
|
*/
|
|
52
56
|
update(path: string, fileBody: ArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | NodeJS.ReadableStream | ReadableStream<Uint8Array> | URLSearchParams | string, fileOptions?: FileOptions): Promise<{
|
|
53
57
|
data: {
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
error:
|
|
58
|
+
path: string;
|
|
59
|
+
};
|
|
60
|
+
error: null;
|
|
61
|
+
} | {
|
|
62
|
+
data: null;
|
|
63
|
+
error: StorageError;
|
|
57
64
|
}>;
|
|
58
65
|
/**
|
|
59
66
|
* Moves an existing file.
|
|
@@ -64,8 +71,11 @@ export declare class StorageFileApi {
|
|
|
64
71
|
move(fromPath: string, toPath: string): Promise<{
|
|
65
72
|
data: {
|
|
66
73
|
message: string;
|
|
67
|
-
}
|
|
68
|
-
error:
|
|
74
|
+
};
|
|
75
|
+
error: null;
|
|
76
|
+
} | {
|
|
77
|
+
data: null;
|
|
78
|
+
error: StorageError;
|
|
69
79
|
}>;
|
|
70
80
|
/**
|
|
71
81
|
* Copies an existing file.
|
|
@@ -76,8 +86,11 @@ export declare class StorageFileApi {
|
|
|
76
86
|
copy(fromPath: string, toPath: string): Promise<{
|
|
77
87
|
data: {
|
|
78
88
|
message: string;
|
|
79
|
-
}
|
|
80
|
-
error:
|
|
89
|
+
};
|
|
90
|
+
error: null;
|
|
91
|
+
} | {
|
|
92
|
+
data: null;
|
|
93
|
+
error: StorageError;
|
|
81
94
|
}>;
|
|
82
95
|
/**
|
|
83
96
|
* Create signed URL to download file without requiring permissions. This URL can be valid for a set number of seconds.
|
|
@@ -88,9 +101,11 @@ export declare class StorageFileApi {
|
|
|
88
101
|
createSignedUrl(path: string, expiresIn: number): Promise<{
|
|
89
102
|
data: {
|
|
90
103
|
signedURL: string;
|
|
91
|
-
}
|
|
92
|
-
error:
|
|
93
|
-
|
|
104
|
+
};
|
|
105
|
+
error: null;
|
|
106
|
+
} | {
|
|
107
|
+
data: null;
|
|
108
|
+
error: StorageError;
|
|
94
109
|
}>;
|
|
95
110
|
/**
|
|
96
111
|
* Create signed URLs to download files without requiring permissions. These URLs can be valid for a set number of seconds.
|
|
@@ -103,8 +118,11 @@ export declare class StorageFileApi {
|
|
|
103
118
|
error: string | null;
|
|
104
119
|
path: string | null;
|
|
105
120
|
signedURL: string;
|
|
106
|
-
}[]
|
|
107
|
-
error:
|
|
121
|
+
}[];
|
|
122
|
+
error: null;
|
|
123
|
+
} | {
|
|
124
|
+
data: null;
|
|
125
|
+
error: StorageError;
|
|
108
126
|
}>;
|
|
109
127
|
/**
|
|
110
128
|
* Downloads a file.
|
|
@@ -112,29 +130,29 @@ export declare class StorageFileApi {
|
|
|
112
130
|
* @param path The file path to be downloaded, including the path and file name. For example `folder/image.png`.
|
|
113
131
|
*/
|
|
114
132
|
download(path: string): Promise<{
|
|
115
|
-
data: Blob
|
|
116
|
-
error:
|
|
133
|
+
data: Blob;
|
|
134
|
+
error: null;
|
|
135
|
+
} | {
|
|
136
|
+
data: null;
|
|
137
|
+
error: StorageError;
|
|
117
138
|
}>;
|
|
118
139
|
/**
|
|
119
|
-
* Retrieve URLs for assets in public buckets
|
|
140
|
+
* Retrieve URLs for assets in public buckets and encapsulates it in a return object
|
|
120
141
|
*
|
|
121
142
|
* @param path The file path to be downloaded, including the path and file name. For example `folder/image.png`.
|
|
122
143
|
*/
|
|
123
|
-
getPublicUrl(path: string):
|
|
124
|
-
data: {
|
|
125
|
-
publicURL: string;
|
|
126
|
-
} | null;
|
|
127
|
-
error: Error | null;
|
|
128
|
-
publicURL: string | null;
|
|
129
|
-
};
|
|
144
|
+
getPublicUrl(path: string): string;
|
|
130
145
|
/**
|
|
131
146
|
* Deletes files within the same bucket
|
|
132
147
|
*
|
|
133
148
|
* @param paths An array of files to be deleted, including the path and file name. For example [`folder/image.png`].
|
|
134
149
|
*/
|
|
135
150
|
remove(paths: string[]): Promise<{
|
|
136
|
-
data: FileObject[]
|
|
137
|
-
error:
|
|
151
|
+
data: FileObject[];
|
|
152
|
+
error: null;
|
|
153
|
+
} | {
|
|
154
|
+
data: null;
|
|
155
|
+
error: StorageError;
|
|
138
156
|
}>;
|
|
139
157
|
/**
|
|
140
158
|
* Get file metadata
|
|
@@ -152,8 +170,11 @@ export declare class StorageFileApi {
|
|
|
152
170
|
* @param parameters Fetch parameters, currently only supports `signal`, which is an AbortController's signal
|
|
153
171
|
*/
|
|
154
172
|
list(path?: string, options?: SearchOptions, parameters?: FetchParameters): Promise<{
|
|
155
|
-
data: FileObject[]
|
|
156
|
-
error:
|
|
173
|
+
data: FileObject[];
|
|
174
|
+
error: null;
|
|
175
|
+
} | {
|
|
176
|
+
data: null;
|
|
177
|
+
error: StorageError;
|
|
157
178
|
}>;
|
|
158
179
|
_getFinalPath(path: string): string;
|
|
159
180
|
_removeEmptyFolders(path: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageFileApi.d.ts","sourceRoot":"","sources":["../../../src/lib/StorageFileApi.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAqB,MAAM,SAAS,CAAA;AAEnE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAiBhE,qBAAa,cAAc;IACzB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IAC5C,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC3B,SAAS,CAAC,KAAK,EAAE,KAAK,CAAA;gBAGpB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,EACvC,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,KAAK;IAQf;;;;;;;;;;OAUG;YACW,cAAc;
|
|
1
|
+
{"version":3,"file":"StorageFileApi.d.ts","sourceRoot":"","sources":["../../../src/lib/StorageFileApi.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,YAAY,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAqB,MAAM,SAAS,CAAA;AAEnE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAiBhE,qBAAa,cAAc;IACzB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,OAA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