'put_object() only accepts keyword arguments.'

Viewed 3795

I am getting the error "'put_object() only accepts keyword arguments.' while uploading a memory uploaded file in S3.

upload_file1 = request.FILES.get('upload_file1')
file_name1 = upload_file1._name
upload_file_path = 'Client/' + client_id + '/' + file_name1
s3.put_object(settings.AWS_STORAGE_BUCKET_NAME,Body=upload_file1,Key=upload_file_path )

please suggest

2 Answers

You are not specifying your Bucket with the parameter name.

Instead it should be

s3.put_object(Bucket=settings.AWS_STORAGE_BUCKET_NAME,Body=upload_file1,Key=upload_file_path )

Mention the parameter name while calling the method. For example:

s3.put_object(Bucket='your_bucket_name', Key='your_key', Body=Data)
Related