Skip to content
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

Multiple image upload at once #1419

Closed
Tushant opened this issue Jan 18, 2016 · 6 comments
Closed

Multiple image upload at once #1419

Tushant opened this issue Jan 18, 2016 · 6 comments

Comments

@Tushant
Copy link

Tushant commented Jan 18, 2016

I am having trouble at uploading multiple image at once.On console i see all the images but only last image is stored on the tastypie.I have also aksed a question on stack overflow but still did not get any solution on this issue.
http://stackoverflow.com/questions/34850160/react-dropzone-multiple-image-at-once-in-tastypie?noredirect=1#comment57445055_34850160

@SeanHayes
Copy link
Member

Answered on SO.

@Tushant
Copy link
Author

Tushant commented Jan 18, 2016

Do i have to create a separate table for image and link that with the Rental Table?Sorry i did not get your reply on SO , so i am asking over here.

@Tushant
Copy link
Author

Tushant commented Jan 19, 2016

If i remove the deserialize part i get an error saying error_message: "The format indicated 'multipart/form-data

@SeanHayes
Copy link
Member

Yes, you'll need the images on another table.

You'll still need your custom deserialize method there to handle the multipart/form-data, which isn't normally supported by tastypie.

REST APIs, and especially tastypie, tend not to handle file uploads well. What I usually do is write a view that accepts file uploads and stores them in a temporary location (something that can be cleaned out regularly via a cron job) and returns a path to that file within the Django storage class used. Then, to add that file to a model, you send the storage path along in a regular JSON request, and on your resource move/copy the file from the temp location to the permanent location.

@Tushant
Copy link
Author

Tushant commented Jan 19, 2016

It seems so complex.I think i should not go with tastypie for handling multiple image upload.
Thanks

@SeanHayes
Copy link
Member

If you want the easiest way to upload files via tastypie, there are recipes out there for base64 encoding your files and putting them in the JSON. It makes your JSON really hard to read though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants