【发布时间】:2015-08-26 02:43:33
【问题描述】:
我使用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 问题、stackoverflow 答案,但无法强制直接上传。 请帮助我,处理这个问题。
【问题讨论】:
标签: java jquery bad-request cloudinary