IJR
IJR

Reputation: 1338

Django API: Upload user files to S3 using Celery to make process async

I have requirement to save user uploaded files to S3 and file url returned back in response. For this I have considered using django-storages. But problem with django-storage will be that file will first be uploaded to server then to S3.

I am trying to make the solution where file is uploaded to server, then a celery task pushes the file to S3. But in this case which URL should I return in response S3(file might not have been uploaded before user requests it) or server URL and have server redirect to S3?

Upvotes: 1

Views: 989

Answers (1)

holdenweb
holdenweb

Reputation: 37003

Since you want to return a value before you know the S3 storage location it clearly can't be the S3 storage location. The best you can do is return a value the user can use to get the S3 storage location from your server when it eventually gets stored (or the information that it's still waiting to be stored).

Upvotes: 2

Related Questions