Using R function put_object from package aws.s3 to load files into a specific S3 bucket

200 Views Asked by At

I can successfully put an object (pdf file) into my S3 bucket base folder using the put_object function from aws.s3. However, it doesn't work when I specify a folder in the function. I don't get any error messages and the output in R looks like it has worked:

[1] TRUE

This is my code:

put_object(file = "myfile.pdf", object = "myfile2.pdf", bucket = "my_bucket", folder = 'folder/subfolder1/subfolder2' )

I've read the package documentation and the post here .

Thanks

1

There are 1 best solutions below

1
On

If you want to create a "folder" in S3 you have to use the other function from the package:

put_folder(folder, bucket, ...)

If you want to put a file inside that "folder" you have to specify the destination key:

put_object(file = "myfile.pdf", object = "folder/subfolder1/subfolder2/myfile2.pdf", bucket = "my_bucket")

As described here.

PS: There are only objects is S3.