@supabase/storage-js 2.12.1 → 2.71.2-canary.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 +0 -15
- package/package.json +11 -17
- package/src/lib/version.ts +2 -2
- package/src/packages/StorageBucketApi.ts +3 -36
- package/src/packages/StorageFileApi.ts +5 -59
- package/LICENSE +0 -201
- package/dist/main/StorageClient.d.ts +0 -18
- package/dist/main/StorageClient.d.ts.map +0 -1
- package/dist/main/StorageClient.js +0 -23
- package/dist/main/StorageClient.js.map +0 -1
- package/dist/main/index.d.ts +0 -4
- package/dist/main/index.d.ts.map +0 -1
- package/dist/main/index.js +0 -22
- package/dist/main/index.js.map +0 -1
- package/dist/main/lib/constants.d.ts +0 -4
- package/dist/main/lib/constants.d.ts.map +0 -1
- package/dist/main/lib/constants.js +0 -6
- package/dist/main/lib/constants.js.map +0 -1
- package/dist/main/lib/errors.d.ts +0 -21
- package/dist/main/lib/errors.d.ts.map +0 -1
- package/dist/main/lib/errors.js +0 -41
- package/dist/main/lib/errors.js.map +0 -1
- package/dist/main/lib/fetch.d.ts +0 -16
- package/dist/main/lib/fetch.d.ts.map +0 -1
- package/dist/main/lib/fetch.js +0 -97
- package/dist/main/lib/fetch.js.map +0 -1
- package/dist/main/lib/helpers.d.ts +0 -12
- package/dist/main/lib/helpers.d.ts.map +0 -1
- package/dist/main/lib/helpers.js +0 -90
- package/dist/main/lib/helpers.js.map +0 -1
- package/dist/main/lib/index.d.ts +0 -5
- package/dist/main/lib/index.d.ts.map +0 -1
- package/dist/main/lib/index.js +0 -21
- package/dist/main/lib/index.js.map +0 -1
- package/dist/main/lib/types.d.ts +0 -148
- package/dist/main/lib/types.d.ts.map +0 -1
- package/dist/main/lib/types.js +0 -3
- package/dist/main/lib/types.js.map +0 -1
- package/dist/main/lib/version.d.ts +0 -2
- package/dist/main/lib/version.d.ts.map +0 -1
- package/dist/main/lib/version.js +0 -6
- package/dist/main/lib/version.js.map +0 -1
- package/dist/main/packages/StorageBucketApi.d.ts +0 -123
- package/dist/main/packages/StorageBucketApi.d.ts.map +0 -1
- package/dist/main/packages/StorageBucketApi.js +0 -204
- package/dist/main/packages/StorageBucketApi.js.map +0 -1
- package/dist/main/packages/StorageFileApi.d.ts +0 -276
- package/dist/main/packages/StorageFileApi.d.ts.map +0 -1
- package/dist/main/packages/StorageFileApi.js +0 -603
- package/dist/main/packages/StorageFileApi.js.map +0 -1
- package/dist/module/StorageClient.d.ts +0 -18
- package/dist/module/StorageClient.d.ts.map +0 -1
- package/dist/module/StorageClient.js +0 -16
- package/dist/module/StorageClient.js.map +0 -1
- package/dist/module/index.d.ts +0 -4
- package/dist/module/index.d.ts.map +0 -1
- package/dist/module/index.js +0 -4
- package/dist/module/index.js.map +0 -1
- package/dist/module/lib/constants.d.ts +0 -4
- package/dist/module/lib/constants.d.ts.map +0 -1
- package/dist/module/lib/constants.js +0 -3
- package/dist/module/lib/constants.js.map +0 -1
- package/dist/module/lib/errors.d.ts +0 -21
- package/dist/module/lib/errors.d.ts.map +0 -1
- package/dist/module/lib/errors.js +0 -34
- package/dist/module/lib/errors.js.map +0 -1
- package/dist/module/lib/fetch.d.ts +0 -16
- package/dist/module/lib/fetch.d.ts.map +0 -1
- package/dist/module/lib/fetch.js +0 -89
- package/dist/module/lib/fetch.js.map +0 -1
- package/dist/module/lib/helpers.d.ts +0 -12
- package/dist/module/lib/helpers.d.ts.map +0 -1
- package/dist/module/lib/helpers.js +0 -60
- package/dist/module/lib/helpers.js.map +0 -1
- package/dist/module/lib/index.d.ts +0 -5
- package/dist/module/lib/index.d.ts.map +0 -1
- package/dist/module/lib/index.js +0 -5
- package/dist/module/lib/index.js.map +0 -1
- package/dist/module/lib/types.d.ts +0 -148
- package/dist/module/lib/types.d.ts.map +0 -1
- package/dist/module/lib/types.js +0 -2
- package/dist/module/lib/types.js.map +0 -1
- package/dist/module/lib/version.d.ts +0 -2
- package/dist/module/lib/version.d.ts.map +0 -1
- package/dist/module/lib/version.js +0 -3
- package/dist/module/lib/version.js.map +0 -1
- package/dist/module/packages/StorageBucketApi.d.ts +0 -123
- package/dist/module/packages/StorageBucketApi.d.ts.map +0 -1
- package/dist/module/packages/StorageBucketApi.js +0 -201
- package/dist/module/packages/StorageBucketApi.js.map +0 -1
- package/dist/module/packages/StorageFileApi.d.ts +0 -276
- package/dist/module/packages/StorageFileApi.d.ts.map +0 -1
- package/dist/module/packages/StorageFileApi.js +0 -600
- package/dist/module/packages/StorageFileApi.js.map +0 -1
- package/dist/umd/supabase.js +0 -1
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { StorageError } from '../lib/errors';
|
|
2
|
-
import { Fetch } from '../lib/fetch';
|
|
3
|
-
import { Bucket, BucketType } from '../lib/types';
|
|
4
|
-
import { StorageClientOptions } from '../StorageClient';
|
|
5
|
-
export default class StorageBucketApi {
|
|
6
|
-
protected url: string;
|
|
7
|
-
protected headers: {
|
|
8
|
-
[key: string]: string;
|
|
9
|
-
};
|
|
10
|
-
protected fetch: Fetch;
|
|
11
|
-
protected shouldThrowOnError: boolean;
|
|
12
|
-
constructor(url: string, headers?: {
|
|
13
|
-
[key: string]: string;
|
|
14
|
-
}, fetch?: Fetch, opts?: StorageClientOptions);
|
|
15
|
-
/**
|
|
16
|
-
* Enable throwing errors instead of returning them.
|
|
17
|
-
*/
|
|
18
|
-
throwOnError(): this;
|
|
19
|
-
/**
|
|
20
|
-
* Retrieves the details of all Storage buckets within an existing project.
|
|
21
|
-
*/
|
|
22
|
-
listBuckets(): Promise<{
|
|
23
|
-
data: Bucket[];
|
|
24
|
-
error: null;
|
|
25
|
-
} | {
|
|
26
|
-
data: null;
|
|
27
|
-
error: StorageError;
|
|
28
|
-
}>;
|
|
29
|
-
/**
|
|
30
|
-
* Retrieves the details of an existing Storage bucket.
|
|
31
|
-
*
|
|
32
|
-
* @param id The unique identifier of the bucket you would like to retrieve.
|
|
33
|
-
*/
|
|
34
|
-
getBucket(id: string): Promise<{
|
|
35
|
-
data: Bucket;
|
|
36
|
-
error: null;
|
|
37
|
-
} | {
|
|
38
|
-
data: null;
|
|
39
|
-
error: StorageError;
|
|
40
|
-
}>;
|
|
41
|
-
/**
|
|
42
|
-
* Creates a new Storage bucket
|
|
43
|
-
*
|
|
44
|
-
* @param id A unique identifier for the bucket you are creating.
|
|
45
|
-
* @param options.public The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations. By default, buckets are private.
|
|
46
|
-
* @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
|
|
47
|
-
* The global file size limit takes precedence over this value.
|
|
48
|
-
* The default value is null, which doesn't set a per bucket file size limit.
|
|
49
|
-
* @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
|
|
50
|
-
* The default value is null, which allows files with all mime types to be uploaded.
|
|
51
|
-
* Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
|
|
52
|
-
* @returns newly created bucket id
|
|
53
|
-
* @param options.type (private-beta) specifies the bucket type. see `BucketType` for more details.
|
|
54
|
-
* - default bucket type is `STANDARD`
|
|
55
|
-
*/
|
|
56
|
-
createBucket(id: string, options?: {
|
|
57
|
-
public: boolean;
|
|
58
|
-
fileSizeLimit?: number | string | null;
|
|
59
|
-
allowedMimeTypes?: string[] | null;
|
|
60
|
-
type?: BucketType;
|
|
61
|
-
}): Promise<{
|
|
62
|
-
data: Pick<Bucket, 'name'>;
|
|
63
|
-
error: null;
|
|
64
|
-
} | {
|
|
65
|
-
data: null;
|
|
66
|
-
error: StorageError;
|
|
67
|
-
}>;
|
|
68
|
-
/**
|
|
69
|
-
* Updates a Storage bucket
|
|
70
|
-
*
|
|
71
|
-
* @param id A unique identifier for the bucket you are updating.
|
|
72
|
-
* @param options.public The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations.
|
|
73
|
-
* @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
|
|
74
|
-
* The global file size limit takes precedence over this value.
|
|
75
|
-
* The default value is null, which doesn't set a per bucket file size limit.
|
|
76
|
-
* @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
|
|
77
|
-
* The default value is null, which allows files with all mime types to be uploaded.
|
|
78
|
-
* Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
|
|
79
|
-
*/
|
|
80
|
-
updateBucket(id: string, options: {
|
|
81
|
-
public: boolean;
|
|
82
|
-
fileSizeLimit?: number | string | null;
|
|
83
|
-
allowedMimeTypes?: string[] | null;
|
|
84
|
-
}): Promise<{
|
|
85
|
-
data: {
|
|
86
|
-
message: string;
|
|
87
|
-
};
|
|
88
|
-
error: null;
|
|
89
|
-
} | {
|
|
90
|
-
data: null;
|
|
91
|
-
error: StorageError;
|
|
92
|
-
}>;
|
|
93
|
-
/**
|
|
94
|
-
* Removes all objects inside a single bucket.
|
|
95
|
-
*
|
|
96
|
-
* @param id The unique identifier of the bucket you would like to empty.
|
|
97
|
-
*/
|
|
98
|
-
emptyBucket(id: string): Promise<{
|
|
99
|
-
data: {
|
|
100
|
-
message: string;
|
|
101
|
-
};
|
|
102
|
-
error: null;
|
|
103
|
-
} | {
|
|
104
|
-
data: null;
|
|
105
|
-
error: StorageError;
|
|
106
|
-
}>;
|
|
107
|
-
/**
|
|
108
|
-
* Deletes an existing bucket. A bucket can't be deleted with existing objects inside it.
|
|
109
|
-
* You must first `empty()` the bucket.
|
|
110
|
-
*
|
|
111
|
-
* @param id The unique identifier of the bucket you would like to delete.
|
|
112
|
-
*/
|
|
113
|
-
deleteBucket(id: string): Promise<{
|
|
114
|
-
data: {
|
|
115
|
-
message: string;
|
|
116
|
-
};
|
|
117
|
-
error: null;
|
|
118
|
-
} | {
|
|
119
|
-
data: null;
|
|
120
|
-
error: StorageError;
|
|
121
|
-
}>;
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=StorageBucketApi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3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,CACJ;CAoBF"}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const constants_1 = require("../lib/constants");
|
|
13
|
-
const errors_1 = require("../lib/errors");
|
|
14
|
-
const fetch_1 = require("../lib/fetch");
|
|
15
|
-
const helpers_1 = require("../lib/helpers");
|
|
16
|
-
class StorageBucketApi {
|
|
17
|
-
constructor(url, headers = {}, fetch, opts) {
|
|
18
|
-
this.shouldThrowOnError = false;
|
|
19
|
-
const baseUrl = new URL(url);
|
|
20
|
-
// if legacy uri is used, replace with new storage host (disables request buffering to allow > 50GB uploads)
|
|
21
|
-
// "project-ref.supabase.co" becomes "project-ref.storage.supabase.co"
|
|
22
|
-
if (opts === null || opts === void 0 ? void 0 : opts.useNewHostname) {
|
|
23
|
-
const isSupabaseHost = /supabase\.(co|in|red)$/.test(baseUrl.hostname);
|
|
24
|
-
if (isSupabaseHost && !baseUrl.hostname.includes('storage.supabase.')) {
|
|
25
|
-
baseUrl.hostname = baseUrl.hostname.replace('supabase.', 'storage.supabase.');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
this.url = baseUrl.href;
|
|
29
|
-
this.headers = Object.assign(Object.assign({}, constants_1.DEFAULT_HEADERS), headers);
|
|
30
|
-
this.fetch = (0, helpers_1.resolveFetch)(fetch);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Enable throwing errors instead of returning them.
|
|
34
|
-
*/
|
|
35
|
-
throwOnError() {
|
|
36
|
-
this.shouldThrowOnError = true;
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Retrieves the details of all Storage buckets within an existing project.
|
|
41
|
-
*/
|
|
42
|
-
listBuckets() {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
try {
|
|
45
|
-
const data = yield (0, fetch_1.get)(this.fetch, `${this.url}/bucket`, { headers: this.headers });
|
|
46
|
-
return { data, error: null };
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
if (this.shouldThrowOnError) {
|
|
50
|
-
throw error;
|
|
51
|
-
}
|
|
52
|
-
if ((0, errors_1.isStorageError)(error)) {
|
|
53
|
-
return { data: null, error };
|
|
54
|
-
}
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Retrieves the details of an existing Storage bucket.
|
|
61
|
-
*
|
|
62
|
-
* @param id The unique identifier of the bucket you would like to retrieve.
|
|
63
|
-
*/
|
|
64
|
-
getBucket(id) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
try {
|
|
67
|
-
const data = yield (0, fetch_1.get)(this.fetch, `${this.url}/bucket/${id}`, { headers: this.headers });
|
|
68
|
-
return { data, error: null };
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
if (this.shouldThrowOnError) {
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
if ((0, errors_1.isStorageError)(error)) {
|
|
75
|
-
return { data: null, error };
|
|
76
|
-
}
|
|
77
|
-
throw error;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Creates a new Storage bucket
|
|
83
|
-
*
|
|
84
|
-
* @param id A unique identifier for the bucket you are creating.
|
|
85
|
-
* @param options.public The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations. By default, buckets are private.
|
|
86
|
-
* @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
|
|
87
|
-
* The global file size limit takes precedence over this value.
|
|
88
|
-
* The default value is null, which doesn't set a per bucket file size limit.
|
|
89
|
-
* @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
|
|
90
|
-
* The default value is null, which allows files with all mime types to be uploaded.
|
|
91
|
-
* Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
|
|
92
|
-
* @returns newly created bucket id
|
|
93
|
-
* @param options.type (private-beta) specifies the bucket type. see `BucketType` for more details.
|
|
94
|
-
* - default bucket type is `STANDARD`
|
|
95
|
-
*/
|
|
96
|
-
createBucket(id, options = {
|
|
97
|
-
public: false,
|
|
98
|
-
}) {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
try {
|
|
101
|
-
const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/bucket`, {
|
|
102
|
-
id,
|
|
103
|
-
name: id,
|
|
104
|
-
type: options.type,
|
|
105
|
-
public: options.public,
|
|
106
|
-
file_size_limit: options.fileSizeLimit,
|
|
107
|
-
allowed_mime_types: options.allowedMimeTypes,
|
|
108
|
-
}, { headers: this.headers });
|
|
109
|
-
return { data, error: null };
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
if (this.shouldThrowOnError) {
|
|
113
|
-
throw error;
|
|
114
|
-
}
|
|
115
|
-
if ((0, errors_1.isStorageError)(error)) {
|
|
116
|
-
return { data: null, error };
|
|
117
|
-
}
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Updates a Storage bucket
|
|
124
|
-
*
|
|
125
|
-
* @param id A unique identifier for the bucket you are updating.
|
|
126
|
-
* @param options.public The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations.
|
|
127
|
-
* @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
|
|
128
|
-
* The global file size limit takes precedence over this value.
|
|
129
|
-
* The default value is null, which doesn't set a per bucket file size limit.
|
|
130
|
-
* @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
|
|
131
|
-
* The default value is null, which allows files with all mime types to be uploaded.
|
|
132
|
-
* Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
|
|
133
|
-
*/
|
|
134
|
-
updateBucket(id, options) {
|
|
135
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
try {
|
|
137
|
-
const data = yield (0, fetch_1.put)(this.fetch, `${this.url}/bucket/${id}`, {
|
|
138
|
-
id,
|
|
139
|
-
name: id,
|
|
140
|
-
public: options.public,
|
|
141
|
-
file_size_limit: options.fileSizeLimit,
|
|
142
|
-
allowed_mime_types: options.allowedMimeTypes,
|
|
143
|
-
}, { headers: this.headers });
|
|
144
|
-
return { data, error: null };
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
if (this.shouldThrowOnError) {
|
|
148
|
-
throw error;
|
|
149
|
-
}
|
|
150
|
-
if ((0, errors_1.isStorageError)(error)) {
|
|
151
|
-
return { data: null, error };
|
|
152
|
-
}
|
|
153
|
-
throw error;
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Removes all objects inside a single bucket.
|
|
159
|
-
*
|
|
160
|
-
* @param id The unique identifier of the bucket you would like to empty.
|
|
161
|
-
*/
|
|
162
|
-
emptyBucket(id) {
|
|
163
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
-
try {
|
|
165
|
-
const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/bucket/${id}/empty`, {}, { headers: this.headers });
|
|
166
|
-
return { data, error: null };
|
|
167
|
-
}
|
|
168
|
-
catch (error) {
|
|
169
|
-
if (this.shouldThrowOnError) {
|
|
170
|
-
throw error;
|
|
171
|
-
}
|
|
172
|
-
if ((0, errors_1.isStorageError)(error)) {
|
|
173
|
-
return { data: null, error };
|
|
174
|
-
}
|
|
175
|
-
throw error;
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Deletes an existing bucket. A bucket can't be deleted with existing objects inside it.
|
|
181
|
-
* You must first `empty()` the bucket.
|
|
182
|
-
*
|
|
183
|
-
* @param id The unique identifier of the bucket you would like to delete.
|
|
184
|
-
*/
|
|
185
|
-
deleteBucket(id) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
try {
|
|
188
|
-
const data = yield (0, fetch_1.remove)(this.fetch, `${this.url}/bucket/${id}`, {}, { headers: this.headers });
|
|
189
|
-
return { data, error: null };
|
|
190
|
-
}
|
|
191
|
-
catch (error) {
|
|
192
|
-
if (this.shouldThrowOnError) {
|
|
193
|
-
throw error;
|
|
194
|
-
}
|
|
195
|
-
if ((0, errors_1.isStorageError)(error)) {
|
|
196
|
-
return { data: null, error };
|
|
197
|
-
}
|
|
198
|
-
throw error;
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
exports.default = StorageBucketApi;
|
|
204
|
-
//# sourceMappingURL=StorageBucketApi.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StorageBucketApi.js","sourceRoot":"","sources":["../../../src/packages/StorageBucketApi.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,gDAAkD;AAClD,0CAA4D;AAC5D,wCAA4D;AAC5D,4CAA6C;AAI7C,MAAqB,gBAAgB;IAMnC,YACE,GAAW,EACX,UAAqC,EAAE,EACvC,KAAa,EACb,IAA2B;QANnB,uBAAkB,GAAG,KAAK,CAAA;QAQlC,MAAM,O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,kBAAkB,EAAE;oBAC3B,MAAM,KAAK,CAAA;iBACZ;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;IAED;;;;;OAKG;IACG,YAAY,CAChB,EAAU;;YAWV,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAA,cAAM,EACvB,IAAI,CAAC,KAAK,EACV,GAAG,IAAI,CAAC,GAAG,WAAW,EAAE,EAAE,EAC1B,EAAE,EACF,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAC1B,CAAA;gBACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;aAC7B;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,IAAI,CAAC,kBAAkB,EAAE;oBAC3B,MAAM,KAAK,CAAA;iBACZ;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;AA/RD,mCA+RC"}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { StorageError } from '../lib/errors';
|
|
3
|
-
import { Fetch } from '../lib/fetch';
|
|
4
|
-
import { FileObject, FileOptions, SearchOptions, FetchParameters, TransformOptions, DestinationOptions, FileObjectV2, Camelize, SearchV2Options, SearchV2Result } from '../lib/types';
|
|
5
|
-
declare type FileBody = ArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | NodeJS.ReadableStream | ReadableStream<Uint8Array> | URLSearchParams | string;
|
|
6
|
-
export default class StorageFileApi {
|
|
7
|
-
protected url: string;
|
|
8
|
-
protected headers: {
|
|
9
|
-
[key: string]: string;
|
|
10
|
-
};
|
|
11
|
-
protected bucketId?: string;
|
|
12
|
-
protected fetch: Fetch;
|
|
13
|
-
protected shouldThrowOnError: boolean;
|
|
14
|
-
constructor(url: string, headers?: {
|
|
15
|
-
[key: string]: string;
|
|
16
|
-
}, bucketId?: string, fetch?: Fetch);
|
|
17
|
-
/**
|
|
18
|
-
* Enable throwing errors instead of returning them.
|
|
19
|
-
*/
|
|
20
|
-
throwOnError(): this;
|
|
21
|
-
/**
|
|
22
|
-
* Uploads a file to an existing bucket or replaces an existing file at the specified path with a new one.
|
|
23
|
-
*
|
|
24
|
-
* @param method HTTP method.
|
|
25
|
-
* @param path The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
26
|
-
* @param fileBody The body of the file to be stored in the bucket.
|
|
27
|
-
*/
|
|
28
|
-
private uploadOrUpdate;
|
|
29
|
-
/**
|
|
30
|
-
* Uploads a file to an existing bucket.
|
|
31
|
-
*
|
|
32
|
-
* @param path The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
33
|
-
* @param fileBody The body of the file to be stored in the bucket.
|
|
34
|
-
*/
|
|
35
|
-
upload(path: string, fileBody: FileBody, fileOptions?: FileOptions): Promise<{
|
|
36
|
-
data: {
|
|
37
|
-
id: string;
|
|
38
|
-
path: string;
|
|
39
|
-
fullPath: string;
|
|
40
|
-
};
|
|
41
|
-
error: null;
|
|
42
|
-
} | {
|
|
43
|
-
data: null;
|
|
44
|
-
error: StorageError;
|
|
45
|
-
}>;
|
|
46
|
-
/**
|
|
47
|
-
* Upload a file with a token generated from `createSignedUploadUrl`.
|
|
48
|
-
* @param path The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
49
|
-
* @param token The token generated from `createSignedUploadUrl`
|
|
50
|
-
* @param fileBody The body of the file to be stored in the bucket.
|
|
51
|
-
*/
|
|
52
|
-
uploadToSignedUrl(path: string, token: string, fileBody: FileBody, fileOptions?: FileOptions): Promise<{
|
|
53
|
-
data: {
|
|
54
|
-
path: string;
|
|
55
|
-
fullPath: any;
|
|
56
|
-
};
|
|
57
|
-
error: null;
|
|
58
|
-
} | {
|
|
59
|
-
data: null;
|
|
60
|
-
error: StorageError;
|
|
61
|
-
}>;
|
|
62
|
-
/**
|
|
63
|
-
* Creates a signed upload URL.
|
|
64
|
-
* Signed upload URLs can be used to upload files to the bucket without further authentication.
|
|
65
|
-
* They are valid for 2 hours.
|
|
66
|
-
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
67
|
-
* @param options.upsert If set to true, allows the file to be overwritten if it already exists.
|
|
68
|
-
*/
|
|
69
|
-
createSignedUploadUrl(path: string, options?: {
|
|
70
|
-
upsert: boolean;
|
|
71
|
-
}): Promise<{
|
|
72
|
-
data: {
|
|
73
|
-
signedUrl: string;
|
|
74
|
-
token: string;
|
|
75
|
-
path: string;
|
|
76
|
-
};
|
|
77
|
-
error: null;
|
|
78
|
-
} | {
|
|
79
|
-
data: null;
|
|
80
|
-
error: StorageError;
|
|
81
|
-
}>;
|
|
82
|
-
/**
|
|
83
|
-
* Replaces an existing file at the specified path with a new one.
|
|
84
|
-
*
|
|
85
|
-
* @param path The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to update.
|
|
86
|
-
* @param fileBody The body of the file to be stored in the bucket.
|
|
87
|
-
*/
|
|
88
|
-
update(path: string, fileBody: ArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | NodeJS.ReadableStream | ReadableStream<Uint8Array> | URLSearchParams | string, fileOptions?: FileOptions): Promise<{
|
|
89
|
-
data: {
|
|
90
|
-
id: string;
|
|
91
|
-
path: string;
|
|
92
|
-
fullPath: string;
|
|
93
|
-
};
|
|
94
|
-
error: null;
|
|
95
|
-
} | {
|
|
96
|
-
data: null;
|
|
97
|
-
error: StorageError;
|
|
98
|
-
}>;
|
|
99
|
-
/**
|
|
100
|
-
* Moves an existing file to a new path in the same bucket.
|
|
101
|
-
*
|
|
102
|
-
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
103
|
-
* @param toPath The new file path, including the new file name. For example `folder/image-new.png`.
|
|
104
|
-
* @param options The destination options.
|
|
105
|
-
*/
|
|
106
|
-
move(fromPath: string, toPath: string, options?: DestinationOptions): Promise<{
|
|
107
|
-
data: {
|
|
108
|
-
message: string;
|
|
109
|
-
};
|
|
110
|
-
error: null;
|
|
111
|
-
} | {
|
|
112
|
-
data: null;
|
|
113
|
-
error: StorageError;
|
|
114
|
-
}>;
|
|
115
|
-
/**
|
|
116
|
-
* Copies an existing file to a new path in the same bucket.
|
|
117
|
-
*
|
|
118
|
-
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
119
|
-
* @param toPath The new file path, including the new file name. For example `folder/image-copy.png`.
|
|
120
|
-
* @param options The destination options.
|
|
121
|
-
*/
|
|
122
|
-
copy(fromPath: string, toPath: string, options?: DestinationOptions): Promise<{
|
|
123
|
-
data: {
|
|
124
|
-
path: string;
|
|
125
|
-
};
|
|
126
|
-
error: null;
|
|
127
|
-
} | {
|
|
128
|
-
data: null;
|
|
129
|
-
error: StorageError;
|
|
130
|
-
}>;
|
|
131
|
-
/**
|
|
132
|
-
* Creates a signed URL. Use a signed URL to share a file for a fixed amount of time.
|
|
133
|
-
*
|
|
134
|
-
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
135
|
-
* @param expiresIn The number of seconds until the signed URL expires. For example, `60` for a URL which is valid for one minute.
|
|
136
|
-
* @param options.download triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
137
|
-
* @param options.transform Transform the asset before serving it to the client.
|
|
138
|
-
*/
|
|
139
|
-
createSignedUrl(path: string, expiresIn: number, options?: {
|
|
140
|
-
download?: string | boolean;
|
|
141
|
-
transform?: TransformOptions;
|
|
142
|
-
}): Promise<{
|
|
143
|
-
data: {
|
|
144
|
-
signedUrl: string;
|
|
145
|
-
};
|
|
146
|
-
error: null;
|
|
147
|
-
} | {
|
|
148
|
-
data: null;
|
|
149
|
-
error: StorageError;
|
|
150
|
-
}>;
|
|
151
|
-
/**
|
|
152
|
-
* Creates multiple signed URLs. Use a signed URL to share a file for a fixed amount of time.
|
|
153
|
-
*
|
|
154
|
-
* @param paths The file paths to be downloaded, including the current file names. For example `['folder/image.png', 'folder2/image2.png']`.
|
|
155
|
-
* @param expiresIn The number of seconds until the signed URLs expire. For example, `60` for URLs which are valid for one minute.
|
|
156
|
-
* @param options.download triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
157
|
-
*/
|
|
158
|
-
createSignedUrls(paths: string[], expiresIn: number, options?: {
|
|
159
|
-
download: string | boolean;
|
|
160
|
-
}): Promise<{
|
|
161
|
-
data: {
|
|
162
|
-
error: string | null;
|
|
163
|
-
path: string | null;
|
|
164
|
-
signedUrl: string;
|
|
165
|
-
}[];
|
|
166
|
-
error: null;
|
|
167
|
-
} | {
|
|
168
|
-
data: null;
|
|
169
|
-
error: StorageError;
|
|
170
|
-
}>;
|
|
171
|
-
/**
|
|
172
|
-
* Downloads a file from a private bucket. For public buckets, make a request to the URL returned from `getPublicUrl` instead.
|
|
173
|
-
*
|
|
174
|
-
* @param path The full path and file name of the file to be downloaded. For example `folder/image.png`.
|
|
175
|
-
* @param options.transform Transform the asset before serving it to the client.
|
|
176
|
-
*/
|
|
177
|
-
download(path: string, options?: {
|
|
178
|
-
transform?: TransformOptions;
|
|
179
|
-
}): Promise<{
|
|
180
|
-
data: Blob;
|
|
181
|
-
error: null;
|
|
182
|
-
} | {
|
|
183
|
-
data: null;
|
|
184
|
-
error: StorageError;
|
|
185
|
-
}>;
|
|
186
|
-
/**
|
|
187
|
-
* Retrieves the details of an existing file.
|
|
188
|
-
* @param path
|
|
189
|
-
*/
|
|
190
|
-
info(path: string): Promise<{
|
|
191
|
-
data: Camelize<FileObjectV2>;
|
|
192
|
-
error: null;
|
|
193
|
-
} | {
|
|
194
|
-
data: null;
|
|
195
|
-
error: StorageError;
|
|
196
|
-
}>;
|
|
197
|
-
/**
|
|
198
|
-
* Checks the existence of a file.
|
|
199
|
-
* @param path
|
|
200
|
-
*/
|
|
201
|
-
exists(path: string): Promise<{
|
|
202
|
-
data: boolean;
|
|
203
|
-
error: null;
|
|
204
|
-
} | {
|
|
205
|
-
data: boolean;
|
|
206
|
-
error: StorageError;
|
|
207
|
-
}>;
|
|
208
|
-
/**
|
|
209
|
-
* A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset.
|
|
210
|
-
* This function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset.
|
|
211
|
-
*
|
|
212
|
-
* @param path The path and name of the file to generate the public URL for. For example `folder/image.png`.
|
|
213
|
-
* @param options.download Triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
214
|
-
* @param options.transform Transform the asset before serving it to the client.
|
|
215
|
-
*/
|
|
216
|
-
getPublicUrl(path: string, options?: {
|
|
217
|
-
download?: string | boolean;
|
|
218
|
-
transform?: TransformOptions;
|
|
219
|
-
}): {
|
|
220
|
-
data: {
|
|
221
|
-
publicUrl: string;
|
|
222
|
-
};
|
|
223
|
-
};
|
|
224
|
-
/**
|
|
225
|
-
* Deletes files within the same bucket
|
|
226
|
-
*
|
|
227
|
-
* @param paths An array of files to delete, including the path and file name. For example [`'folder/image.png'`].
|
|
228
|
-
*/
|
|
229
|
-
remove(paths: string[]): Promise<{
|
|
230
|
-
data: FileObject[];
|
|
231
|
-
error: null;
|
|
232
|
-
} | {
|
|
233
|
-
data: null;
|
|
234
|
-
error: StorageError;
|
|
235
|
-
}>;
|
|
236
|
-
/**
|
|
237
|
-
* Get file metadata
|
|
238
|
-
* @param id the file id to retrieve metadata
|
|
239
|
-
*/
|
|
240
|
-
/**
|
|
241
|
-
* Update file metadata
|
|
242
|
-
* @param id the file id to update metadata
|
|
243
|
-
* @param meta the new file metadata
|
|
244
|
-
*/
|
|
245
|
-
/**
|
|
246
|
-
* Lists all the files and folders within a path of the bucket.
|
|
247
|
-
* @param path The folder path.
|
|
248
|
-
* @param options Search options including limit (defaults to 100), offset, sortBy, and search
|
|
249
|
-
*/
|
|
250
|
-
list(path?: string, options?: SearchOptions, parameters?: FetchParameters): Promise<{
|
|
251
|
-
data: FileObject[];
|
|
252
|
-
error: null;
|
|
253
|
-
} | {
|
|
254
|
-
data: null;
|
|
255
|
-
error: StorageError;
|
|
256
|
-
}>;
|
|
257
|
-
/**
|
|
258
|
-
* @experimental this method signature might change in the future
|
|
259
|
-
* @param options search options
|
|
260
|
-
* @param parameters
|
|
261
|
-
*/
|
|
262
|
-
listV2(options?: SearchV2Options, parameters?: FetchParameters): Promise<{
|
|
263
|
-
data: SearchV2Result;
|
|
264
|
-
error: null;
|
|
265
|
-
} | {
|
|
266
|
-
data: null;
|
|
267
|
-
error: StorageError;
|
|
268
|
-
}>;
|
|
269
|
-
protected encodeMetadata(metadata: Record<string, any>): string;
|
|
270
|
-
toBase64(data: string): string;
|
|
271
|
-
private _getFinalPath;
|
|
272
|
-
private _removeEmptyFolders;
|
|
273
|
-
private transformOptsToQueryString;
|
|
274
|
-
}
|
|
275
|
-
export {};
|
|
276
|
-
//# sourceMappingURL=StorageFileApi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StorageFileApi.d.ts","sourceRoot":"","sources":["../../../src/packages/StorageFileApi.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,YAAY,EAAuB,MAAM,eAAe,CAAA;AACjF,OAAO,EAAE,KAAK,EAAgC,MAAM,cAAc,CAAA;AAElE,OAAO,EACL,UAAU,EACV,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,cAAc,EACf,MAAM,cAAc,CAAA;AAiBrB,aAAK,QAAQ,GACT,WAAW,GACX,eAAe,GACf,IAAI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