Skip to content

Commit fdfb120

Browse files
authored
Return ID and full path of uploaded file (#168)
* feat: return id and full path of uploaded file * feat: return full path for signed url upload
1 parent f1b754c commit fdfb120

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/packages/StorageFileApi.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default class StorageFileApi {
6868
fileOptions?: FileOptions
6969
): Promise<
7070
| {
71-
data: { path: string }
71+
data: { id: string, path: string, fullPath: string }
7272
error: null
7373
}
7474
| {
@@ -106,13 +106,15 @@ export default class StorageFileApi {
106106
...(options?.duplex ? { duplex: options.duplex } : {}),
107107
})
108108

109+
const data = await res.json()
110+
109111
if (res.ok) {
110112
return {
111-
data: { path: cleanPath },
113+
data: { path: cleanPath, id: data.Id, fullPath: data.Key },
112114
error: null,
113115
}
114116
} else {
115-
const error = await res.json()
117+
const error = data
116118
return { data: null, error }
117119
}
118120
} catch (error) {
@@ -192,13 +194,15 @@ export default class StorageFileApi {
192194
headers,
193195
})
194196

197+
const data = await res.json()
198+
195199
if (res.ok) {
196200
return {
197-
data: { path: cleanPath },
201+
data: { path: cleanPath, fullPath: data.Key },
198202
error: null,
199203
}
200204
} else {
201-
const error = await res.json()
205+
const error = data
202206
return { data: null, error }
203207
}
204208
} catch (error) {

0 commit comments

Comments
 (0)