wavespeed 0.0.6 → 0.0.8
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -102,11 +102,19 @@ class WaveSpeed {
|
|
|
102
102
|
async fetchWithTimeout(path, options = {}) {
|
|
103
103
|
const { timeout = this.timeout * 1000, ...fetchOptions } = options;
|
|
104
104
|
// Ensure headers exist
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
if (options.isUpload) {
|
|
106
|
+
fetchOptions.headers = {
|
|
107
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
108
|
+
...(fetchOptions.headers || {}),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
fetchOptions.headers = {
|
|
113
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
114
|
+
'content-type': 'application/json',
|
|
115
|
+
...(fetchOptions.headers || {}),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
110
118
|
// Default retry options
|
|
111
119
|
const maxRetries = options.maxRetries || 3;
|
|
112
120
|
const initialBackoff = 1000; // 1 second
|
|
@@ -232,6 +240,9 @@ class WaveSpeed {
|
|
|
232
240
|
const form = new FormData();
|
|
233
241
|
form.append('file', file);
|
|
234
242
|
// Only set Authorization header; browser will set Content-Type
|
|
243
|
+
if (options == null) {
|
|
244
|
+
options = { isUpload: true };
|
|
245
|
+
}
|
|
235
246
|
const response = await this.fetchWithTimeout('media/upload/binary', {
|
|
236
247
|
method: 'POST',
|
|
237
248
|
body: form,
|