azure media services - The request body is too large and exceeds the maximum permissible limit

心不动则不痛 提交于 2020-01-24 09:37:45

问题


I am using the java SDK and followed the example on: https://docs.microsoft.com/en-us/azure/media-services/media-services-java-how-to-use However, using this example, for files larget than ~65MB I got the following error: RequestBodyTooLargeThe request body is too large and exceeds the maximum permissible limit. Any idea? Thanks,


回答1:


The current version of the Media Services Java SDK has a limitation on the size of the file to upload when using the provided createBlockBlob method.

To workaround this, you can leverage the file upload through the Azure Storage Java SDK if you need to upload files larger than 64MB. To do this, update the example as follows:

1) For example, if you are using Gradle build tool, add this line to the build.gradle file under the dependencies section: (package)

dependencies { 
  // ...
  compile group: 'com.microsoft.azure', name: 'azure-storage', version: '4.0.0'
}

2) Add the following import directives to your code:

import com.microsoft.azure.storage.blob.CloudBlobContainer;
import com.microsoft.azure.storage.blob.CloudBlockBlob;

3) Replace the following block of code of the uploadFileAndCreateAsset method

// Create the Blob Writer using the Locator
uploader = mediaService.createBlobWriter(uploadLocator);

File file = new File("BigBuckBunny.mp4"); 

// The local file that will be uploaded to your Media Services account
InputStream input = new FileInputStream(file);

System.out.println("Uploading " + fileName);

// Upload the local file to the asset
uploader.createBlockBlob(fileName, input);

With the following block of code:

try {
    CloudBlobContainer container = new CloudBlobContainer(URI.create(uploadLocator.getPath()));

    // The blob reference of the asset file
    CloudBlockBlob blob = container.getBlockBlobReference("BigBuckBunny.mp4");

    // The local file that will be uploaded to your Media Services account
    File sourceFile = new File("BigBuckBunny.mp4");

    // Upload the local file to the asset
    blob.upload(new FileInputStream(sourceFile), sourceFile.length());

} catch (Exception e) {
    // Track the exception
    e.printStackTrace();
}


来源:https://stackoverflow.com/questions/45958465/azure-media-services-the-request-body-is-too-large-and-exceeds-the-maximum-per

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!