Cloudinary Java直接上传BAD REQUEST错误

Cloudinary Java direct upload BAD REQUEST error

我使用 Java 构建 图片上传 标签:

Map options = ObjectUtils.asMap("resource_type", "auto");
options.put("callback", "http://localhost:8080/cloudinary_cors.html");
Map htmlOptions = null;
String html = cloudinary.uploader().imageUploadTag("image_id", options, htmlOptions);

将此字符串放入模型属性并显示在页面上。看起来像按钮 "Choose file".

选择了一些图像,jquery.fileupload 尝试将此图像发送到 Cloudinary。

我接受了 状态代码:400 错误请求 和响应:

error: {message: "Upload preset must be specified when using unsigned upload"}

我的所有设置都是正确的,我可以使用以下代码从服务器端发送图像:

Map uploadResult = cloudinary.uploader().upload("image.jpg", ObjectUtils.emptyMap())

但我无法从客户端发送文件。

页面代码:

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <script th:src="@{/js/common/jquery-1.11.3.min.js}" type="text/javascript"/>
    <script th:src="@{/js/cloudinary/jquery.ui.widget.js}" type="text/javascript"/>
    <script th:src="@{/js/cloudinary/jquery.iframe-transport.js}" type="text/javascript"/>
    <script th:src="@{/js/cloudinary/jquery.fileupload.js}" type="text/javascript"/>
    <script th:src="@{/js/cloudinary/jquery.cloudinary.js}" type="text/javascript"/>
</head>
<body>
    <span th:utext="${cloudyURL}" th:remove="tag"></span>
    <!-- config CloudinaryApi -->
    <script th:inline="javascript">
          $.cloudinary.config({"cloud_name":"CLOUDNAME", "api_key":"APIKEY"});
    </script>
</body>
</html>

我阅读了所有 Cloudinary 手册、github 问题、Whosebug 答案,但无法强制直接上传。 请帮助我,处理这个问题。

Upload preset must be specified 错误响应通常意味着签名未作为上传选项的一部分传递。您可以将 URL 分享到演示此内容的实时网页吗?

您能否也分享一下如何生成输入字段的演示(即在 'Developer tools' 下显示)?

如果涉及隐私问题,请随时联系 Cloudinary 的支持团队。

此外,您可以查看示例项目(https://github.com/cloudinary/cloudinary_java/tree/master/samples)