-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uploading broken files to Amazon S3 #31
Comments
@lebedev-yury Have you been able to take a look at this yet? |
Hi! You are experiencing the problem only with pdf file uploads, or with other file types too? |
It's the same for images too. The content type saved is text/html
|
You mean that when you open the url to the uploaded file, it shows the file as plain in the browser? If yes, this might be a problem with incorrect content-disposition, set in your amazon s3 |
Hey @lebedev-yury , |
I think you misunderstand the concept of base64 encoded uploads. How do you think your web application would get the file contents from your local machine, by just having the address? Base64 string should contain the contents of the file, that you want to upload, encoded in base64 string |
Hi Yuri,
|
Hi @lebedev-yury , |
I'm using mongoid along with carrierwave to upload files using JSON API. My controller method looks like this-
Model
While the whole process works great, the file uploaded to S3 (pdf in this case) has no content in it.
I believe this has something to do with StringIO being used to read the file from the system. It sets the content_type to plain/text. This is confirmed when I download the pdf and try to open it on my system.
Here's my json I'm using to upload -
{
"content": {
"campus" : "569df3c4be84c511c0000001",
"course" : "569dfe1cbe84c511c0000006",
"subject" : "56a0c4debe84c50d2f000006",
"batch" : "2015",
"title" : "RipAndSave",
"asset": "data:application/pdf;base64,L2hvbWUvbW9qby9Eb3dubG9hZHMvc2FtcGxlLnBkZg=="
}
}
I'm using Rails 4.2, Mongoid 5.1
Can you help?
The text was updated successfully, but these errors were encountered: