Cron job for file upload

(Samitha Palihawadana) #1

In django rest framework, I can upload files into ‘local path’ or ‘s3 bucket’ directly. My Question is first I want to upload files into local path and after one minute I want to upload it into s3 bucket. But in API GET should be display the s3 bucket path url for files.

(Vitor Freitas) #2

Not sure if a cron job is the best way to achieve this. Because the cron job is a task that is executed in some interval of time. For example, every 10 minutes, every hour, every day at some specific hour, etc.

But in your case, the action is performed after some event. So maybe Celery is the best option.

So the user upload the file to your app, and inside your view, you register an async task to upload the file to your S3 bucket.

But the async task would be executed as soon as there is resource available, so this might be before your one minute rule. If you want to delay it a bit then you could play with celery-beat or try to find some dynamic scheduling app for Django