Cloudinary Java direct upload BAD REQUEST error

1.3k views Asked by At

I used Java for building Image upload tag:

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);

Put this String to Model attribute and show on page. Looks like button "Choose file".

Picked some image and jquery.fileupload tried to send this image to Cloudinary.

I took Status Code: 400 Bad Request and response:

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

All of my settings is right, I can send image from server side, using this code:

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

but I can't send file from client side.

Code of page:

<!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>

I read all of Cloudinary manuals, github issues, stackoverflow answers but can't force working direct upload. Please help me, deal with this problem.

1

There are 1 answers

3
Itay Taragano On BEST ANSWER

An Upload preset must be specified error response usually means that the signature isn't passed as part of the upload options. Can you share a URL to a live webpage where this is demonstrated?

Can you also share a demonstration of how the input field is generated (i.e., show it under the 'Developer tools')?

If privacy is an issue, please feel free to contact Cloudinary's support team.

Also, you can have a look at the Sample project(https://github.com/cloudinary/cloudinary_java/tree/master/samples)