Created
January 12, 2022 19:38
-
-
Save michiboo/5104b5662c5c848926247bff635d04be to your computer and use it in GitHub Desktop.
This file contains 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
import time | |
import nft_storage | |
from nft_storage.api import nft_storage_api | |
from nft_storage.model.error_response import ErrorResponse | |
from nft_storage.model.upload_response import UploadResponse | |
from nft_storage.model.unauthorized_error_response import UnauthorizedErrorResponse | |
from nft_storage.model.forbidden_error_response import ForbiddenErrorResponse | |
from pprint import pprint | |
# The client must configure the authentication and authorization parameters | |
# in accordance with the API server security policy. | |
# Examples for each auth method are provided below, use the example that | |
# satisfies your auth use case. | |
# Configure Bearer authorization (JWT): bearerAuth | |
configuration = nft_storage.Configuration( | |
access_token = '' # enter your API key here | |
) | |
# Enter a context with an instance of the API client | |
with nft_storage.ApiClient(configuration) as api_client: | |
# Create an instance of the API class | |
api_instance = nft_storage_api.NFTStorageAPI(api_client) | |
for i in range(1, 11): | |
body = open(f'./generatedImage/{i}.png', 'rb') # path to your image | |
try: | |
# Store a file | |
api_response = api_instance.store(body) | |
pprint(api_response) | |
except nft_storage.ApiException as e: | |
print("Exception when calling NFTStorageAPI->store: %s\n" % e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment