Skip to content

Commit

Permalink
fix: consistent return types for copy (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
fenos authored Sep 22, 2022
1 parent 38fb1d9 commit d741c3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/packages/StorageFileApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export default class StorageFileApi {
toPath: string
): Promise<
| {
data: { message: string }
data: { path: string }
error: null
}
| {
Expand All @@ -243,7 +243,7 @@ export default class StorageFileApi {
{ bucketId: this.bucketId, sourceKey: fromPath, destinationKey: toPath },
{ headers: this.headers }
)
return { data, error: null }
return { data: { path: data.Key }, error: null }
} catch (error) {
if (isStorageError(error)) {
return { data: null, error }
Expand Down
5 changes: 1 addition & 4 deletions test/storageFileApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ describe('Object API', () => {
const res = await storage.from(bucketName).copy(uploadPath, newPath)

expect(res.error).toBeNull()

// TODO: current types are wrong, workaround for now
// @ts-ignore
expect(res.data?.Key).toEqual(`${bucketName}/${newPath}`)
expect(res.data?.path).toEqual(`${bucketName}/${newPath}`)
})

test('downloads an object', async () => {
Expand Down

0 comments on commit d741c3d

Please sign in to comment.