@oasis-path/gamma-sdk 1.0.23 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.uploadWithToken = uploadWithToken;
|
|
4
4
|
async function uploadWithToken(options, baseUrl) {
|
|
5
|
-
const { file, filename, mimeType,
|
|
5
|
+
const { file, filename, mimeType, token } = options;
|
|
6
6
|
const formData = new FormData();
|
|
7
7
|
// Handle different file input types
|
|
8
8
|
if (typeof Buffer !== 'undefined' && file instanceof Buffer) {
|
|
@@ -17,7 +17,7 @@ async function uploadWithToken(options, baseUrl) {
|
|
|
17
17
|
// Blob or File
|
|
18
18
|
formData.append('file', file, filename);
|
|
19
19
|
}
|
|
20
|
-
const url = new URL(
|
|
20
|
+
const url = new URL('/api/files/upload-presigned', baseUrl);
|
|
21
21
|
url.searchParams.append('token', token);
|
|
22
22
|
const response = await fetch(url.toString(), {
|
|
23
23
|
method: 'POST',
|
|
@@ -41,7 +41,12 @@ async function makeTrpcRequest(method, path, baseUrl, apiKey, options) {
|
|
|
41
41
|
}
|
|
42
42
|
const contentType = response.headers.get('content-type');
|
|
43
43
|
if (contentType?.includes('application/json')) {
|
|
44
|
-
|
|
44
|
+
const jsonResponse = await response.json();
|
|
45
|
+
// Unwrap nested result.data structure if present
|
|
46
|
+
if (jsonResponse?.result?.data) {
|
|
47
|
+
return jsonResponse.result.data;
|
|
48
|
+
}
|
|
49
|
+
return jsonResponse;
|
|
45
50
|
}
|
|
46
51
|
return response;
|
|
47
52
|
}
|