Created
January 1, 2021 21:44
-
-
Save koepnick/5672dd3c0593f8c6cd102242a48510a4 to your computer and use it in GitHub Desktop.
Connecting Colab to an external storage provider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You only need ro run the install command once per kernel change | |
!pip install s3fs | |
import s3fs | |
fs = s3fs.S3FileSystem( | |
anon = False, | |
key = 'YOURKEY', | |
secret = 'YOURSECRET', | |
client_kwargs = { | |
'endpoint_url': 'https://some.s3.provider/' | |
} | |
) | |
# This is a silly example that eschews elegance for clarity | |
file_list = fs.listdir('/some/path') | |
file_object = file_list[0] | |
file_data = fs.open(file_object['Key']) | |
# Now treat it as a binary byte stream | |
from PIL import Image | |
png = Image.open(image_data) | |
display(png) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment