@@ -10,12 +10,14 @@ class StorageFileApi {
10
10
final Map <String , String > headers;
11
11
final String ? bucketId;
12
12
final int _retryAttempts;
13
+ final Fetch _storageFetch;
13
14
14
15
const StorageFileApi (
15
16
this .url,
16
17
this .headers,
17
18
this .bucketId,
18
19
this ._retryAttempts,
20
+ this ._storageFetch,
19
21
);
20
22
21
23
String _getFinalPath (String path) {
@@ -51,7 +53,7 @@ class StorageFileApi {
51
53
assert (retryAttempts == null || retryAttempts >= 0 ,
52
54
'retryAttempts has to be greater or equal to 0' );
53
55
final finalPath = _getFinalPath (path);
54
- final response = await storageFetch .postFile (
56
+ final response = await _storageFetch .postFile (
55
57
'$url /object/$finalPath ' ,
56
58
file,
57
59
fileOptions,
@@ -86,7 +88,7 @@ class StorageFileApi {
86
88
assert (retryAttempts == null || retryAttempts >= 0 ,
87
89
'retryAttempts has to be greater or equal to 0' );
88
90
final finalPath = _getFinalPath (path);
89
- final response = await storageFetch .postBinaryFile (
91
+ final response = await _storageFetch .postBinaryFile (
90
92
'$url /object/$finalPath ' ,
91
93
data,
92
94
fileOptions,
@@ -121,7 +123,7 @@ class StorageFileApi {
121
123
var url = Uri .parse ('${this .url }/object/upload/sign/$finalPath ' );
122
124
url = url.replace (queryParameters: {'token' : token});
123
125
124
- await storageFetch .putFile (
126
+ await _storageFetch .putFile (
125
127
url.toString (),
126
128
file,
127
129
fileOptions,
@@ -155,7 +157,7 @@ class StorageFileApi {
155
157
var url = Uri .parse ('${this .url }/object/upload/sign/$path0 ' );
156
158
url = url.replace (queryParameters: {'token' : token});
157
159
158
- await storageFetch .putBinaryFile (
160
+ await _storageFetch .putBinaryFile (
159
161
url.toString (),
160
162
data,
161
163
fileOptions,
@@ -175,7 +177,7 @@ class StorageFileApi {
175
177
Future <SignedUploadURLResponse > createSignedUploadUrl (String path) async {
176
178
final finalPath = _getFinalPath (path);
177
179
178
- final data = await storageFetch .post (
180
+ final data = await _storageFetch .post (
179
181
'$url /object/upload/sign/$finalPath ' ,
180
182
{},
181
183
options: FetchOptions (headers: headers),
@@ -220,7 +222,7 @@ class StorageFileApi {
220
222
assert (retryAttempts == null || retryAttempts >= 0 ,
221
223
'retryAttempts has to be greater or equal to 0' );
222
224
final finalPath = _getFinalPath (path);
223
- final response = await storageFetch .putFile (
225
+ final response = await _storageFetch .putFile (
224
226
'$url /object/$finalPath ' ,
225
227
file,
226
228
fileOptions,
@@ -256,7 +258,7 @@ class StorageFileApi {
256
258
assert (retryAttempts == null || retryAttempts >= 0 ,
257
259
'retryAttempts has to be greater or equal to 0' );
258
260
final finalPath = _getFinalPath (path);
259
- final response = await storageFetch .putBinaryFile (
261
+ final response = await _storageFetch .putBinaryFile (
260
262
'$url /object/$finalPath ' ,
261
263
data,
262
264
fileOptions,
@@ -276,7 +278,7 @@ class StorageFileApi {
276
278
/// `folder/image-new.png` .
277
279
Future <String > move (String fromPath, String toPath) async {
278
280
final options = FetchOptions (headers: headers);
279
- final response = await storageFetch .post (
281
+ final response = await _storageFetch .post (
280
282
'$url /object/move' ,
281
283
{
282
284
'bucketId' : bucketId,
@@ -297,7 +299,7 @@ class StorageFileApi {
297
299
/// `folder/image-copy.png` .
298
300
Future <String > copy (String fromPath, String toPath) async {
299
301
final options = FetchOptions (headers: headers);
300
- final response = await storageFetch .post (
302
+ final response = await _storageFetch .post (
301
303
'$url /object/copy' ,
302
304
{
303
305
'bucketId' : bucketId,
@@ -326,7 +328,7 @@ class StorageFileApi {
326
328
}) async {
327
329
final finalPath = _getFinalPath (path);
328
330
final options = FetchOptions (headers: headers);
329
- final response = await storageFetch .post (
331
+ final response = await _storageFetch .post (
330
332
'$url /object/sign/$finalPath ' ,
331
333
{
332
334
'expiresIn' : expiresIn,
@@ -354,7 +356,7 @@ class StorageFileApi {
354
356
int expiresIn,
355
357
) async {
356
358
final options = FetchOptions (headers: headers);
357
- final response = await storageFetch .post (
359
+ final response = await _storageFetch .post (
358
360
'$url /object/sign/$bucketId ' ,
359
361
{
360
362
'expiresIn' : expiresIn,
@@ -391,7 +393,7 @@ class StorageFileApi {
391
393
fetchUrl = fetchUrl.replace (queryParameters: queryParams);
392
394
393
395
final response =
394
- await storageFetch .get (fetchUrl.toString (), options: options);
396
+ await _storageFetch .get (fetchUrl.toString (), options: options);
395
397
return response as Uint8List ;
396
398
}
397
399
@@ -424,7 +426,7 @@ class StorageFileApi {
424
426
/// name. For example: `remove(['folder/image.png'])` .
425
427
Future <List <FileObject >> remove (List <String > paths) async {
426
428
final options = FetchOptions (headers: headers);
427
- final response = await storageFetch .delete (
429
+ final response = await _storageFetch .delete (
428
430
'$url /object/$bucketId ' ,
429
431
{'prefixes' : paths},
430
432
options: options,
@@ -451,7 +453,7 @@ class StorageFileApi {
451
453
...searchOptions.toMap (),
452
454
};
453
455
final options = FetchOptions (headers: headers);
454
- final response = await storageFetch .post (
456
+ final response = await _storageFetch .post (
455
457
'$url /object/list/$bucketId ' ,
456
458
body,
457
459
options: options,
0 commit comments