Passing Files as Binary in Server Actions
Answered
African Slender-snouted Crocodil… posted this in #help-forum
African Slender-snouted CrocodileOP
This is how the file is being PUT on my Presigned URL (POSTMAN IMAGE). Now I want to implement the same thing in my server Actions but it seems not to be working. Can anyone help?
Answered by B33fb0n3
why don't you call the upload directly from the client? I don't see any need of a server action there
10 Replies
@African Slender-snouted Crocodile This is how the file is being PUT on my Presigned URL (POSTMAN IMAGE). Now I want to implement the same thing in my server Actions but it seems not to be working. Can anyone help?
why don't you call the upload directly from the client? I don't see any need of a server action there
Answer
African Slender-snouted CrocodileOP
Faced with localhost:3000 CORS issues when I call directly from client.
@African Slender-snouted Crocodile Faced with localhost:3000 CORS issues when I call directly from client.
yea, the browser don't send specific headers on localhost. Use this extension to upload it directly from client. In production it should be fine (without the extension): https://chromewebstore.google.com/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf
You can also configure your extension, so it can only access on localhost:
African Slender-snouted CrocodileOP
Still same even when I use the extension
@African Slender-snouted Crocodile Still same even when I use the extension
Use the „POST“ Method to upload. iirc s3 only Support post form uploads. So change your method to post. Also check your CORS settings in s3
@African Slender-snouted Crocodileworked?
African Slender-snouted CrocodileOP
Yes please. I think the issue was related to the content type and yes the POST request as well. Thank you🙏🏾🙏🏾
And yes I did it on client-side
perfect. Happy to help