当我通过Django将图像上传到亚马逊的S3时,图像大小几乎翻倍。例如,我将图像上传到Django是17.4KB,但是当我查看我的S3存储桶时,图像为33.2KB。
有没有理由发生这种情况?以下是我的表单和视图,以查看进程。我似乎无法弄清楚为什么会这样。
forms.py:
class PhotoUploadForm(forms.ModelForm):
class Meta:
model = Photo
fields = ('photo',)
views.py:
@login_required
def photo_upload(request):
form = PhotoUploadForm(request.POST or None,
request.FILES or None,
request=request)
if request.method == 'POST':
if form.is_valid():
obj = form.save(commit=False)
obj.creator = request.user
obj.slug = get_random_string(length=10)
obj.save()
return HttpResponseRedirect(reverse('home'))
return render(request, 'photos/photo_upload.html', {'form': form})
提前感谢您的帮助!