DyfanJones / s3fs

Access Amazon Web Service 'S3' as if it were a file system. File system 'API' design around R package 'fs'
https://dyfanjones.github.io/s3fs/
Other
41 stars 1 forks source link

add minio s3 examples #2

Closed DyfanJones closed 1 year ago

jkh1 commented 1 year ago

Trying to use s3fs to access files on a minio server with code like this:

s3_file_system(aws_access_key_id = "key_id",  
               aws_secret_access_key = "secret_key", 
               region_name = "", 
               endpoint = "https://example.com",
               s3_force_path_style = TRUE) 
s3_file_info("bucket_name/file_name")

results in Error in get_region(cfgs$credentials$profile) : No region provided It looks as if whatever is given as region_name is ignored. Is this a bug or am I going about it wrong?

Thx

DyfanJones commented 1 year ago

hi @jkh1,

Sorry about the delay in the minio s3 example. If you remove the region_name it should work. Here is an example of me creating minio s3 on my local machine :)

library(s3fs)

s3_file_system(
  aws_access_key_id = "minioadmin",  
  aws_secret_access_key = "minioadmin", 
  endpoint = "http://localhost:9000"
)

s3_dir_ls()
#> [1] ""

s3_bucket_create("s3://testbucket")
#> [1] "s3://testbucket"

# refresh cache
s3_dir_ls(refresh = T)
#> [1] "s3://testbucket"

s3_bucket_delete("s3://testbucket")
#> [1] "s3://testbucket"

# refresh cache
s3_dir_ls(refresh = T)
#> [1] ""

Created on 2022-12-14 with reprex v2.0.2

Please let me know if your having any difficulty :)

I will add this example to the readme 😄

jkh1 commented 1 year ago

@DyfanJones Thanks for the prompt reply. If I remove region_name from s3_file_system(), I get Error in get_region(profile_name) : No region provided It seems the profile mentioned in the errors refer to profiles from an AWS config file that paws can use so could it be that s3fs/paws is looking for missing data in a profile which I don't have since I am not using AWS?

DyfanJones commented 1 year ago

Ah I see, I guess you haven't set up any .aws/credentials or .aws/config files. No worries you can set a default aws region for example: us-east-1 and it should connect file.

library(s3fs)

s3_file_system(
  aws_access_key_id = "minioadmin",  
  aws_secret_access_key = "minioadmin",
  region = "us-east-1",
  endpoint = "http://localhost:9000",
  refresh = T
)

s3_dir_ls()
#> [1] ""

s3_bucket_create("s3://testbucket")
#> [1] "s3://testbucket"

# refresh cache
s3_dir_ls(refresh = T)
#> [1] "s3://testbucket"

s3_bucket_delete("s3://testbucket")
#> [1] "s3://testbucket"

# refresh cache
s3_dir_ls(refresh = T)
#> [1] ""

Created on 2022-12-14 with reprex v2.0.2

I wonder if I should set that as a backup if it fails to get an aws region 🤔

jkh1 commented 1 year ago

This works although I had tried us-east-1 before, maybe the refresh option did the trick. Thanks.

DyfanJones commented 1 year ago

@jkh1 I have set a default region so you shouldn't get that error again :) I have also added the minio s3 example. please feel free to re-open this ticket if you come across the same issue again.