我试图上传到亚马逊s3的图像。图像在对象中“request.FILES文件['image']”如下面的代码所示。我的问题是,boto3“upload\u file()”函数需要一个指向图像的路径,而另一方面,我有一个内存中的图像对象,因此我得到了这个错误。raise ValueError('Filename must be a string')
ValueError: Filename must be a string
我的密码在这里。你知道吗
@csrf_protect
def file_upload_view(request):
if request.method == 'POST':
img_list = request.FILES['image']
s3 = boto3.client('s3')
s3.upload_file(img_list, settings.AWS_STORAGE_BUCKET_NAME, img_list.name)
else:
print('not post...')
return HttpResponse([{}], content_type='application/json')
如有任何意见,我们将不胜感激。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐