Uploading MP3 audio to AWS S3

That’s progress - the [0] did fix the error you had before.

The new error is because the final argument to upload_file should be a string, but you’re passing file which is a Media Object.

The final argument is the S3 Key which is S3’s equivalent of a filename. So if you pass something like "path/to/my/file/" + row["filename"] then it should work

s3_client.meta.client.upload_file(
  file_name,
  'wspyradio',
  "path/to/my/file" + row["filename"],
)

Although S3 might not like spaces in keys so perhaps "path/to/my/file" + row["filename"].replace(" ", "-")

1 Like