How to copy a file from one path to another using django storage and amazon S3?

im = storage.open('old_path_filename', 'r') strorage.save('new_path_with_old_filename', im) 

In my django project, I use django repositories and amazon S3 for my static and multimedia files. I do not want to save the old file with the new path in amazon and the old file name. could you help me?

+4
source share
1 answer

You can use Django ContentFile for this.

 from django.core.files.base import ContentFile new_file = ContentFile(original_file.read()) new_file.name = original_file.name example = Example() example.file = new_file example.save() 
+3
source

Source: https://habr.com/ru/post/1484218/


All Articles