Skip to content

Commit c1d7336

Browse files
committed
add checker s3 func for uri
1 parent 2fd00f0 commit c1d7336

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

activestorage/active.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pathlib
66
import urllib
77
import pyfive
8+
import requests
89
import s3fs
910
import time
1011

@@ -18,6 +19,13 @@
1819
from activestorage.hdf2numcodec import decode_filters
1920

2021

22+
def storage_is_s3(uri):
23+
resp = requests.head(uri)
24+
response = resp.headers["gateway-protocol"]
25+
if response == "s3":
26+
return True
27+
28+
2129
def load_from_s3(uri, storage_options=None):
2230
"""
2331
Load a netCDF4-like object from S3.
@@ -53,7 +61,8 @@ def load_from_s3(uri, storage_options=None):
5361

5462
def load_from_https(uri):
5563
"""
56-
Load a Dataset from a netCDF4 file on an https server (NGINX).
64+
Load a pyfive.high_level.Dataset from a
65+
netCDF4 file on an https server (NGINX).
5766
"""
5867
#TODO need to test if NGINX server behind https://
5968
fs = fsspec.filesystem('http')

0 commit comments

Comments
 (0)