关于使用https://nft.storage/,我想用他免费的空间。

def async_store(app,body,api_instance):
    try:
        # Store a file
        api_response = api_instance.store(body,async_req=True)
        pprint(api_response)
        # 执行到这里就弹异常了,东西实际上传上去了的。但是我要获取那个上传后的CID
        res = api_response.get()
    except nft_storage.ApiException as e:
        print("Exception when calling NFTStorageAPI->store: %s\n" % e)
def nft_store(body):
    from app import app
    with nft_storage.ApiClient(configuration) as api_client:
        # Create an instance of the API class
        api_instance = nft_storage_api.NFTStorageAPI(api_client)
        # example passing only required values which don't have defaults set
        Thread(target=async_store, args=(app, body,api_instance)).start()

 

#异常弹出这个。。。实在不知道怎么弄。我也是新手小白。

nft_storage.exceptions.ApiValueError: Invalid value for `type` (image/png), must be one of ['directory', 'image/jpeg', 'application/json', 'other mime types']

异常提示只能选择must be one of ['directory', 'image/jpeg', 'application/json', 'other mime types']这几种数据类型,你的是(image/png),不是其中的数据类型

如果对你有帮助,可以点击我这个回答右上方的【采纳】按钮,给我个采纳吗,谢谢

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632