11👍
this way you do not download content to save it
# Bucket: bucket name
# Key: file path
from storages.backends.s3boto3 import S3Boto3Storage
s3 = S3Boto3Storage()
def copy(Bucket_A, Bucket_B, Key_A, Key_B):
copy_source = {'Bucket': Bucket_A, 'Key': Key_A}
s3.bucket.meta.client.copy(copy_source, Bucket_B, Key_B)
s3.delete(Key_A)
return Key_B
def move(Bucket_A, Bucket_B, Key_A, Key_B):
copy(Bucket_A, Bucket_B, Key_A, Key_B)
s3.delete(Key_A)
return Key_B
9👍
You can use Django’s ContentFile
to do 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()
- HTML5 number input field step attribute broken in Internet Explorer 10 and Internet Explorer 11
- IntegrityError: null value in column "city_id " violates not-null constraint
- Using django-rest-interface with http put
Source:stackexchange.com