我正在使用可恢复的js在laravel wepapp中的JWPlayer上上传视频

时间:2019-10-14 11:49:13

标签: laravel jwplayer resumablejs

我正在使用可恢复的js在laravel wepapp中的JWPlayer上上传视频。当我上传视频时。它只会在jwp仪表板上上传第一段视频,然后在“网络”标签中返回以下错误。

a:4:{s:6:"status";s:5:"error";s:7:"message";s:72:"Uploads for the media files with the status `processing` are not allowed";s:4:"code";s:16:"PermissionDenied";s:5:"title";s:17:"Permission Denied";}

由于后两个,我正在寻找解决方案。参见下面我的可恢复js代码。我在jwp服务器上传递了1mb的存储块。但是在第一个块之后,它说“不允许上传状态为processing的媒体文件”,因为我在上面提到了完整的错误消息。

var $ = window.$; // use the global jQuery instance

var $fileUpload = $('#resumable-browse');
var $fileUploadDrop = $('#resumable-drop');
var $uploadList = $("#file-upload-list");

if ($fileUpload.length > 0 && $fileUploadDrop.length > 0) {
    console.log($fileUpload.data('url'));
  var resumable = new Resumable({
    // Use chunk size that is smaller than your maximum limit due a resumable issue
    // https://github.com/23/resumable.js/issues/51
    chunkSize: 1 * 1024 * 1024,
    // 1MB
    method: "POST",
    simultaneousUploads: 1,
    testChunks: false,
    throttleProgressCallbacks: 1,
    // Get the url from data-url tag
    target: $fileUpload.data('url'),
     headers: {
       "X-Session-Id":$("#jwToken").val(),
    },
    // Append token to the request - required for web routes

    query: {
      _token: $('input[name=_token]').val()
    }
  }); // Resumable.js isn't supported, fall back on a different method

  if (!resumable.support) {
    $('#resumable-error').show();
  } else {
    // Show a place for dropping/selecting files
    $fileUploadDrop.show();
    resumable.assignDrop($fileUpload[0]);
    resumable.assignBrowse($fileUploadDrop[0]); // Handle file add event

    resumable.on('fileAdded', function (file) {
      // Show progress pabr
      $uploadList.show(); // Show pause, hide resume

      $('.resumable-progress .progress-resume-link').hide();
      $('.resumable-progress .progress-pause-link').show(); // Add the file to the list

      $uploadList.append('<li class="resumable-file-' + file.uniqueIdentifier + '">Processing <span class="resumable-file-name"></span> <span class="resumable-file-progress"></span>');
      $('.resumable-file-' + file.uniqueIdentifier + ' .resumable-file-name').html(file.fileName); // Actually start the upload

      resumable.upload();
    });
    resumable.on('fileSuccess', function (file, message) {
      // Reflect that the file upload has completed
      $('.resumable-file-' + file.uniqueIdentifier + ' .resumable-file-progress').html('(completed)');
    });
    resumable.on('fileError', function (file, message) {
      // Reflect that the file upload has resulted in error
      $('.resumable-file-' + file.uniqueIdentifier + ' .resumable-file-progress').html('(file could not be uploaded: ' + message + ')');
    });
    resumable.on('fileProgress', function (file) {
      // Handle progress for both the file and the overall upload
      $('.resumable-file-' + file.uniqueIdentifier + ' .resumable-file-progress').html(Math.floor(file.progress() * 100) + '%');
      $('.progress-bar').css({
        width: Math.floor(resumable.progress() * 100) + '%'
      });
    });
  }
}

/***/ }),

1 个答案:

答案 0 :(得分:1)

在创建视频时,请确保您指定了multipart upload method

还要确保您要上传到的位置是create调用中返回的位置(该位置应到达/v1/videos/upload/resumable端点)。 This guide应该提供有关该过程的更多详细信息。