File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -201,10 +201,22 @@ def get_filepath_or_buffer(
201
201
if filepath_or_buffer .startswith ("s3n://" ):
202
202
filepath_or_buffer = filepath_or_buffer .replace ("s3n://" , "s3://" )
203
203
fsspec = import_optional_dependency ("fsspec" )
204
+ from botocore .exceptions import NoCredentialsError
205
+
206
+ try :
207
+ file_obj = fsspec .open (
208
+ filepath_or_buffer , mode = mode or "rb" , ** (storage_options or {})
209
+ ).open ()
210
+ # GH 34626 Reads from Public Buckets without Credentials needs anon=True
211
+ except NoCredentialsError :
212
+ if storage_options is None :
213
+ storage_options = {"anon" : True }
214
+ else :
215
+ storage_options ["anon" ] = True
216
+ file_obj = fsspec .open (
217
+ filepath_or_buffer , mode = mode or "rb" , ** (storage_options or {})
218
+ ).open ()
204
219
205
- file_obj = fsspec .open (
206
- filepath_or_buffer , mode = mode or "rb" , ** (storage_options or {})
207
- ).open ()
208
220
return file_obj , encoding , compression , True
209
221
210
222
if isinstance (filepath_or_buffer , (str , bytes , mmap .mmap )):
You can’t perform that action at this time.
0 commit comments