Skip to content

Commit e25a70d

Browse files
authored
fix(storage_client): prevent the SDK from throwing when null path was returned from calling createSignedUrls() (supabase#599)
* fix: add test case for createSignedUrls * format document * log returned value * upload file in test before getting signed urls * log response * pass a fall back empty string for path * update comments
1 parent e5ba4fe commit e25a70d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/storage_client/lib/src/storage_file_api.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,9 @@ class StorageFileApi {
363363
);
364364
final List<SignedUrl> urls = (response as List).map((e) {
365365
return SignedUrl(
366-
path: e['path'],
366+
// Prevents exceptions being thrown when null value is returned
367+
// https://github.com/supabase/storage-api/issues/353
368+
path: e['path'] ?? '',
367369
signedUrl: '$url${e['signedURL']}',
368370
);
369371
}).toList();

packages/storage_client/test/client_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ void main() {
7171
final response = await storage.createBucket(newBucketName);
7272
expect(response, newBucketName);
7373
});
74+
test('createSignedUrls does not throw', () async {
75+
await storage.from(newBucketName).upload(uploadPath, file);
76+
await storage.from(newBucketName).createSignedUrls([uploadPath], 2000);
77+
});
7478

7579
test('Create new public bucket', () async {
7680
const newPublicBucketName = 'my-new-public-bucket';

0 commit comments

Comments
 (0)