upload file image is broken with rest api

Added by huy nguyen 6 months ago

i used rest api
POST /uploads.xml?filename=image.png
Content-Type: application/octet-stream
...
(request body is the file content)

  1. 201 response
    <upload>
    <token>7167.ed1ccdb093229ca1bd0b043618d88743</token>
    </upload>

file has upload to server success, file format pdf, exe, zip, rar... active oke but file format image/png, image/jpeg, video/mp4 not open

My code:

const data = new FormData();
data.append('file', event.target.files[0]);
$.ajax({
type: "POST",
url: IP_ADDRESS_REDMINE + '/uploads.json?filename=' + event.target.files[0].name,
data: data,
dataType: "JSON",
processData: false,
filename: event.target.files[0].name,
headers: {
'Authorization': `Basic ${basic_token}`,
'Content-Type': 'application/octet-stream',
},
error: function (response) {
}
}).done(function (res) {
});

pic_e.png - image not open in website (30.7 KB)

not-open.PNG - after download not open image (47.6 KB)

Replies (1)

RE: upload file image is broken with rest api - Added by Federico Vergelli 3 months ago

Same.

Have you fixed it? or discover what went wrong?

(1-1/1)