You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There doesn't seem to be a separate repo for the REST API, so I'm putting this here.
Background: I'm using Deno, which gives error: Uncaught Error: Dynamic require of "proxy-agent" is not supported when I try to import via https://esm.sh/[email protected]. Maybe worth opening a separate issue for that, but my use case is pretty simple, so I'd prefer to just use a simple fetch request rather than adding bloat by pulling in a whole SDK.
Explain your use case
I'm trying to upload a file via POST request. Everything seems to be working OK, except when the file name contains non-ASCII characters. For example, if public_id in my request is "蜡笔小新", the public_id returned in the response is "è�¡ç¬�å°�æ�°".
When I run the Node SDK in runkit, I notice it deals gracefully with UTF-8 public_ids, but I can't figure out how from skimming the code. Perhaps this should be added to the documentation? Not sure if it counts as a bug per se, but usually I just assume modern web APIs will automatically use UTF-8 as default.
Describe the problem you’re trying to solve
My code looks like this:
constconfig={cloudName: getEnvVar('CLOUDINARY_CLOUD_NAME'),apiKey: getEnvVar('CLOUDINARY_API_KEY'),secretKey: getEnvVar('CLOUDINARY_SECRET_KEY'),}consturl=`https://api.cloudinary.com/v1_1/${config.cloudName}/image/upload`constopts={public_id: file.name.split('.').slice(0,-1).join('.'),timestamp: String(Math.floor(Date.now()/1000)),// use_filename: true,}// don't use any URL encoding etc. otherwise signature won't workconstnaiveQps=Object.keys(opts).sort().map(k=>`${k}=${opts[kaskeyoftypeofopts]}`).join('&')constsignature=toHashString(awaitcrypto.subtle.digest('SHA-1',newTextEncoder().encode(naiveQps+config.secretKey)),)constformData=newFormData()for(const[k,v]ofObject.entries({
...opts,
file,api_key: config.apiKey,
signature,})){formData.append(k,v)}constres=awaitfetch(url,{method: 'POST',body: formData})constdata: CloudinaryResponseData=awaitres.json()
If I comment out public_id and uncomment use_filename under opts, the same problem still occurs (for a filename of "蜡笔小新.gif").
The text was updated successfully, but these errors were encountered:
Would you please open up a support ticket with our team at [email protected] as we will need to enable an account level flag to enable special characters as a public_id.
Edit: Looks like the issue is on my end — either there's something wrong with the file, Postman is doing something weird with the encoding, or the framework I'm using is. Closing for now. @rnamba-cloudinary thanks for your help! 🙏
There doesn't seem to be a separate repo for the REST API, so I'm putting this here.
Background: I'm using Deno, which gives
error: Uncaught Error: Dynamic require of "proxy-agent" is not supported
when I try to import via https://esm.sh/[email protected]. Maybe worth opening a separate issue for that, but my use case is pretty simple, so I'd prefer to just use a simplefetch
request rather than adding bloat by pulling in a whole SDK.Explain your use case
I'm trying to upload a file via POST request. Everything seems to be working OK, except when the file name contains non-ASCII characters. For example, if
public_id
in my request is "蜡笔小新", thepublic_id
returned in the response is "����".When I run the Node SDK in runkit, I notice it deals gracefully with UTF-8
public_id
s, but I can't figure out how from skimming the code. Perhaps this should be added to the documentation? Not sure if it counts as a bug per se, but usually I just assume modern web APIs will automatically use UTF-8 as default.Describe the problem you’re trying to solve
My code looks like this:
If I comment out
public_id
and uncommentuse_filename
underopts
, the same problem still occurs (for a filename of "蜡笔小新.gif").The text was updated successfully, but these errors were encountered: