Describe the bug
If you call the http form function to produce a Body that includes both a Byte array file the correct mime type isn't used and what gets uploaded is a unicode text file instead of an image.
Example:
Reproduction
Call the fetch api with a body created by Body.form(...) with an end result similar to:
{someKey: {file: byteArray, mime: 'image/png', fileName: 'aFile.png'}
Where "someKey" is what your server expects to be the key in the form containing the file and byteArray is an array of numbers, each number between (-128, 127).
An example byte array (in plain text) is attached (for the Tauri logo):

The file will be correctly uploaded, however it will simply be a text file, not binary (image) if in linux you run the command file -i img.png it will show a mime type of plain text.
As a control simply perform the upload specifying an absolute path to the image file:
{someKey: {file: 'path/to/file', mime: 'image/png', fileName: 'filename.png'}}
And this works great! So we know it is only an issue when supplying a byte array as file
Expected behavior
The file should have mime type of image/png
Platform and versions
Linux (Ubuntu 20.04, Centos 7, Windows 10)
[build-dependencies]
tauri-build = { version = "1.0.0-rc.12", features = [] }
[dependencies]
tauri = { version = "1.0.0-rc.14", features = ["fs-read-file", "fs-write-file", "http-all", "http-multipart", "shell-open"] }
Stack trace
No response
Additional context
I tried adding reqwest-client but that resulted in it completely not uploading at all with my server rejecting:
org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
Describe the bug
If you call the http
formfunction to produce a Body that includes both a Byte arrayfilethe correct mime type isn't used and what gets uploaded is a unicode text file instead of an image.Example:
Reproduction
Call the
fetchapi with a body created byBody.form(...)with an end result similar to:Where "someKey" is what your server expects to be the key in the form containing the file and
byteArrayis an array of numbers, each number between (-128, 127).An example byte array (in plain text) is attached (for the Tauri logo):

The file will be correctly uploaded, however it will simply be a text file, not binary (image) if in linux you run the command
file -i img.pngit will show a mime type of plain text.As a control simply perform the upload specifying an absolute path to the image file:
And this works great! So we know it is only an issue when supplying a byte array as
fileExpected behavior
The file should have mime type of
image/pngPlatform and versions
Linux (Ubuntu 20.04, Centos 7, Windows 10) [build-dependencies] tauri-build = { version = "1.0.0-rc.12", features = [] } [dependencies] tauri = { version = "1.0.0-rc.14", features = ["fs-read-file", "fs-write-file", "http-all", "http-multipart", "shell-open"] }Stack trace
No response
Additional context
I tried adding
reqwest-clientbut that resulted in it completely not uploading at all with my server rejecting: