Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 云计算错误:“quot;请通过api eu.cloudinary.com访问“;_Python_Python 3.x_Cloudinary - Fatal编程技术网

Python 云计算错误:“quot;请通过api eu.cloudinary.com访问“;

Python 云计算错误:“quot;请通过api eu.cloudinary.com访问“;,python,python-3.x,cloudinary,Python,Python 3.x,Cloudinary,当我尝试通过Python将图像上载到Cloudinary时,如下所示: import cloudinary.uploader cloudinary.config( cloud_name = 'our-name-eu', api_key = '…', api_secret = '…', private_cdn = True, secure_distribution = 'our-name-eu-res.cloudinary.com' ) cloudinary.uploader

当我尝试通过Python将图像上载到Cloudinary时,如下所示:

import cloudinary.uploader

cloudinary.config(
  cloud_name = 'our-name-eu',
  api_key = '…',
  api_secret = '…',
  private_cdn = True,
  secure_distribution = 'our-name-eu-res.cloudinary.com'
)
cloudinary.uploader.upload("https://i.ytimg.com/vi/2fb-g_V-UT4/hqdefault.jpg")
然后我得到以下错误:

错误:云我们的名字eu属于eu geo,请通过api eu.cloudinary.com访问

而API URL的结构类似于
https://api.cloudinary.com/v1_1///upload
我假设我可以用
api eu
替换
api
,但我不知道如何在Python模块中指定这一点

我正在使用Python 3.7.2和
pip
中的
cloudinary
包查看:

似乎相关的配置键是
upload\u prefix


为了便于参考,我在Python文件的repo中搜索了默认值:。

看起来是
upload\u前缀:
:@jornsharpe!你想写个答案让我接受吗?
def cloudinary_api_url(action='upload', **options):
    cloudinary_prefix = options.get("upload_prefix", cloudinary.config().upload_prefix)\
                        or "https://api.cloudinary.com"
    cloud_name = options.get("cloud_name", cloudinary.config().cloud_name)
    if not cloud_name:
        raise ValueError("Must supply cloud_name")
    resource_type = options.get("resource_type", "image")

    return encode_unicode_url("/".join([cloudinary_prefix, "v1_1", cloud_name, resource_type, action]))