Cloudinary 上传器不适用于大型视频

Cloudinary uploader not working with large videos

我正在生成一个带有 Java 的输入标签,用于直接从浏览器上传视频,使用 Cloudinary API,它适用于小视频,但不适用于50 MB 一个。

这是生成输入标签的代码:

String html = cloudinary.uploader().imageUploadTag("file", options, htmlOptions);

Map options = ObjectUtils.asMap("resource_type", "video");
    options.put("callback", "/cloudinary_cors.html");
    options.put("eager", eager);
    options.put("eager_async", true);
    options.put("tags", videoTags);
    options.put("use_filename", true);

Map htmlOptions = ObjectUtils.asMap();
    htmlOptions.put("id", "videoInput");
    htmlOptions.put("class", "upload");

这是生成的输入标签的示例:

<input type="file" name="file" 
       data-url="https://api.cloudinary.com/v1_1/rentalwebs/video/upload" 
       data-form-data="{"eager":"c_scale,h_720,w_1280","signature":"xxxfb0c461dxxx",
       "api_key":"xxx1647231xxx","eager_async":true,
       "callback":"/cloudinary_cors.html","tags":"Demo Website,1,Villa Demo 2",
       "use_filename":true,"timestamp":"1548357724"}" 
       data-cloudinary-field="file" class="cloudinary-fileupload upload" id="videoInput">

最后,这些是附加到带有输入标签的页面的 .js 脚本:

<script th:src="@{/js/jquery.ui.widget.js}" type='text/javascript'></script>
<script th:src="@{/js/load-image.all.min.js}" type='text/javascript'></script>
<script th:src="@{/js/canvas-to-blob.min.js}" type='text/javascript'></script>
<script th:src="@{/js/jquery.iframe-transport.js}" type='text/javascript'></script>
<script th:src="@{/js/jquery.fileupload.js}" type='text/javascript'></script>
<script th:src="@{/js/jquery.fileupload-process.js}" type='text/javascript'></script>
<script th:src="@{/js/jquery.fileupload-image.js}" type='text/javascript'></script>
<script th:src="@{/js/jquery.fileupload-validate.js}" type='text/javascript'></script>
<script th:src="@{/js/jquery.cloudinary.js}" type='text/javascript'></script>


$(document).ready(function() {
              if($.fn.cloudinary_fileupload !== undefined) {
                $("input.cloudinary-fileupload[type=file]").cloudinary_fileupload();
                }
            });

我可能遗漏了一些我一直找不到的东西。还有一些代码,处理上传过程和结果,但我想问题出现在我在这个问题上附上的代码中。

看来您只需要将参数 chunk_size 添加到 Java 中的选项映射。这应该将 chunk_size 传递给构建 javascript cloudinary_fileupload 的 blueimp。

我会添加 20 MB 的块大小,例如options.put("chunk_size", 20000000);