Skip to content

Commit

Permalink
Return ID and full path of uploaded file (#168)
Browse files Browse the repository at this point in the history
* feat: return id and full path of uploaded file

* feat: return full path for signed url upload
  • Loading branch information
bombillazo authored Nov 14, 2023
1 parent f1b754c commit fdfb120
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/packages/StorageFileApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class StorageFileApi {
fileOptions?: FileOptions
): Promise<
| {
data: { path: string }
data: { id: string, path: string, fullPath: string }
error: null
}
| {
Expand Down Expand Up @@ -106,13 +106,15 @@ export default class StorageFileApi {
...(options?.duplex ? { duplex: options.duplex } : {}),
})

const data = await res.json()

if (res.ok) {
return {
data: { path: cleanPath },
data: { path: cleanPath, id: data.Id, fullPath: data.Key },
error: null,
}
} else {
const error = await res.json()
const error = data
return { data: null, error }
}
} catch (error) {
Expand Down Expand Up @@ -192,13 +194,15 @@ export default class StorageFileApi {
headers,
})

const data = await res.json()

if (res.ok) {
return {
data: { path: cleanPath },
data: { path: cleanPath, fullPath: data.Key },
error: null,
}
} else {
const error = await res.json()
const error = data
return { data: null, error }
}
} catch (error) {
Expand Down

0 comments on commit fdfb120

Please sign in to comment.