Skip to content

Commit

Permalink
fix(storage_client): prevent the SDK from throwing when null path was…
Browse files Browse the repository at this point in the history
… returned from calling `createSignedUrls()` (#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
  • Loading branch information
dshukertjr committed Aug 23, 2023
1 parent e5ba4fe commit e25a70d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/storage_client/lib/src/storage_file_api.dart
Expand Up @@ -363,7 +363,9 @@ class StorageFileApi {
);
final List<SignedUrl> urls = (response as List).map((e) {
return SignedUrl(
path: e['path'],
// Prevents exceptions being thrown when null value is returned
// https://github.com/supabase/storage-api/issues/353
path: e['path'] ?? '',
signedUrl: '$url${e['signedURL']}',
);
}).toList();
Expand Down
4 changes: 4 additions & 0 deletions packages/storage_client/test/client_test.dart
Expand Up @@ -71,6 +71,10 @@ void main() {
final response = await storage.createBucket(newBucketName);
expect(response, newBucketName);
});
test('createSignedUrls does not throw', () async {
await storage.from(newBucketName).upload(uploadPath, file);
await storage.from(newBucketName).createSignedUrls([uploadPath], 2000);
});

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

0 comments on commit e25a70d

Please sign in to comment.