Presigned Url image upload get response

I am uploading an images using a presigned url currently this is my response
uploadResult
Response {type: 'cors', url: 'https://s3.eu-west-1.amazonaws.com/foobar', redirected: false, status: 204, ok: true, …}
body: ReadableStream
bodyUsed: false
headers: Headers {}
ok: true
redirected: false
status: 204
statusText: "No Content"
type: "cors"
url: "https://s3.eu-west-1.amazonaws.com/foobar"[[Prototype]]: Response
uploadResult
Response {type: 'cors', url: 'https://s3.eu-west-1.amazonaws.com/foobar', redirected: false, status: 204, ok: true, …}
body: ReadableStream
bodyUsed: false
headers: Headers {}
ok: true
redirected: false
status: 204
statusText: "No Content"
type: "cors"
url: "https://s3.eu-west-1.amazonaws.com/foobar"[[Prototype]]: Response
This is the method I used:
const formData = new FormData();

Object.entries({ ...fields, file }).forEach(([key, value]) => {
formData.append(key, value as string);
});

const upload = await fetch(url, {
method: 'POST',
body: formData,
});

console.log('uploadResult', upload);
const formData = new FormData();

Object.entries({ ...fields, file }).forEach(([key, value]) => {
formData.append(key, value as string);
});

const upload = await fetch(url, {
method: 'POST',
body: formData,
});

console.log('uploadResult', upload);
I am wondering if I actually successfully uploaded the file, can I check that using the response from upload somehow?
7 Replies
utdev
utdevOP3y ago
If I download the "image", it says file is corrupted and if I rename the extension to .txt it says [Object Object] 😡
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
utdev
utdevOP3y ago
yes let me check to be sure yes defining it like this
const uniqueName = `${uuid()}-${filename}`;

const result = this.s3.createPresignedPost({
Bucket: this.s3Bucket,
Fields: {
key: uniqueName,
'Content-Type': filetype,
},
Expires: 60 * 5,
Conditions: [
['content-length-range', 0, 1048576 * 10], // up to 10 MB
],
});
const uniqueName = `${uuid()}-${filename}`;

const result = this.s3.createPresignedPost({
Bucket: this.s3Bucket,
Fields: {
key: uniqueName,
'Content-Type': filetype,
},
Expires: 60 * 5,
Conditions: [
['content-length-range', 0, 1048576 * 10], // up to 10 MB
],
});
If I log the filetype and name I get this uploading a jpg image, so that should be correct
{
"filename": "foo.jpeg",
"filetype": "image/jpeg"
}
{
"filename": "foo.jpeg",
"filetype": "image/jpeg"
}
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
utdev
utdevOP3y ago
yes the fie was uploaded but if I download that file from aws it has the same issue
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
utdev
utdevOP3y ago
I can try that
Want results from more Discord servers?
Add your server