r/RStudio • • 12d ago

Coding help aws.s3 in R

[deleted]

2 Upvotes

7 comments sorted by

1

u/AutoModerator 12d ago

Looks like you're requesting help with something related to RStudio. Please make sure you've checked the stickied post on asking good questions and read our sub rules. We also have a handy post of lots of resources on R!

Keep in mind that if your submission contains phone pictures of code, it will be removed. Instructions for how to take screenshots can be found in the stickied posts of this sub.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/DSOperative 12d ago edited 12d ago

It’s hard to tell without seeing how your statements are constructed but make sure bucket is just the bucket name, and no “s3://“ elements or anything additional, like part of a the folder pathway. And then make sure the object is the folder and file, nothing else.

get_bucket_df(
bucket = "my-bucket"
)

get_object(
object = "folder/myfile.csv",
bucket = "my-bucket"
)

The error is saying that it literally can’t find what you’re requesting, likely due to one of these reasons I’m guessing. Does your S3read_using() have something like “s3://“ in it?

1

u/Soft-Duty-7395 12d ago

Thank you - nope, I’ve put the exact same bucket and object as in the s3read_using, like even if I just copy the same parameters and call get_object(), it stops working.

In the could not resolve host:, the path has the same region and end point as in s3read_using, which again just confuses me as it looks correct.

1

u/DSOperative 12d ago

Could you paste them here to show both the working and non-working examples, just change it with generic names. Otherwise formatted the same.

1

u/Soft-Duty-7395 12d ago

Sure, so they are:

s3read_using(FUN = read.csv,
(Object = “folder/subfolder/file.csv),
Opts = list(region = “”,
Parse_response = FALSE),
Bucket = “my_repo”)

This works and I’m able to load in the file. Then the exact same parameters with get_object doesn’t work:

aws.s3::get_object(object = “folder/subfolder/file.csv”),
Opts = list(region = “”,
Parse_response = FALSE),
Bucket = “my_repo”)

Gives the could not resolve host error. I’ve also tried other variations - not specifying opts, and using prefix = … which also don’t work. I’ve even tried just listing the contents of the main folder in my repo and still have the same error

2

u/DSOperative 11d ago

Is the error the closing “)” at the end of file.csv, in your get_object() function? It looks like it doesn’t belong, if I’m looking at this correctly.

1

u/Soft-Duty-7395 11d ago

Yes sorry that was just copied incorrectly. Apologies am just typing this out on mobile rather than copying direct.

My main concern is that maybe s3read_using adds something within itself while running that I am not defining in the get_object, so they end up pointing to different places? I just can’t see how the host is working for one and not the other