我尝试直接从我的前端(角度8)使用cloudinary API_URL上传文件,但仍然收到相同的错误请求(400)和相同的错误"Upload preset必须被列入未签名上传的白名单“,即使我尝试了不同的解决方案,如在FormData中提供preset_name,并在我的cloudinary设置中将预设设置为unsigned,但仍然无效。有什么解决方案吗?
我的上传代码:
const images = new FormData();
images.append('images', file);
images.append('upload_preset', [presetName]);
this.progressBar = true
const req = new HttpRequest('POST', 'https://api.cloudinary.com/v1_1/[cloudName]/image/upload', images,
{
reportProgress: true,
});
this.http.request(req).subscribe(event => {
if (event.type === HttpEventType.UploadProgress) {
const percentDone = Math.round(100 * event.loaded / event.total);
console.log(`File is ${percentDone}% uploaded.`);
} else if (event instanceof HttpResponse) {
console.log('File is completely uploaded!');
}
});发布于 2020-07-18 00:20:57
Upload preset must be whitelisted for unsigned uploads错误表示您正在使用的预设被标记为签名上载。由于您没有执行经过身份验证的API调用,即使用签名,因此上传预设必须设置为未签名。如果您尚未设置,请转到您帐户中的设置->上传选项卡,并验证您正在尝试使用的预设的签名模式是否设置为未签名。
此外,我看到您正在传递一个名为'images‘的参数。这不是Upload接口的有效参数。请将其更新为“文件”。
const data = new FormData();
data.append("file", file);
data.append("upload_preset", "default-preset");https://stackoverflow.com/questions/62957684
复制相似问题