Skip to content

Commit 0be63e1

Browse files
authored
Update http.android.ts
Make the name property more consistent.
1 parent 6e331ed commit 0be63e1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/http.android.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,20 @@ export function buildJavaOptions(options: HttpRequestOptions) {
280280
formDataPartMediaType = okhttp3.MediaType.parse(value.type);
281281
}
282282

283+
const filename = value.name || "";
283284
if (value.data instanceof ArrayBuffer) {
284285
const typedArray = new Uint8Array(value.data as ArrayBuffer);
285286
const nativeBuffer = java.nio.ByteBuffer.wrap(Array.from(typedArray));
286-
builder.addFormDataPart(key, value.name, okhttp3.RequestBody.create(formDataPartMediaType, nativeBuffer.array()));
287+
builder.addFormDataPart(key, filename, okhttp3.RequestBody.create(formDataPartMediaType, nativeBuffer.array()));
287288
} else if (value.data instanceof Blob) {
288289
// Stolen from core xhr, not sure if we should use InternalAccessor, but it provides fast access.
289290
// @ts-ignore
290291
const typedArray = new Uint8Array(Blob.InternalAccessor.getBuffer(value.data).buffer.slice(0) as ArrayBuffer);
291292
const nativeBuffer = java.nio.ByteBuffer.wrap(Array.from(typedArray));
292-
builder.addFormDataPart(key, value.name, okhttp3.RequestBody.create(formDataPartMediaType, nativeBuffer.array()));
293+
builder.addFormDataPart(key, filename, okhttp3.RequestBody.create(formDataPartMediaType, nativeBuffer.array()));
293294
} else {
294295
// Support for native file objects.
295-
builder.addFormDataPart(key, value.name, okhttp3.RequestBody.create(formDataPartMediaType, value.data));
296+
builder.addFormDataPart(key, filename, okhttp3.RequestBody.create(formDataPartMediaType, value.data));
296297
}
297298
} else {
298299
// Support for native file objects.

0 commit comments

Comments
 (0)