当前版本的媒体服务 Java SDK 对使用提供的上传文件大小有限制创建块Blob method.
要解决此问题,您可以通过以下方式利用文件上传Azure 存储 Java SDK https://github.com/azure/azure-storage-java如果您需要上传大于 64MB 的文件。为此,请按如下方式更新示例:
1) 例如,如果您使用 Gradle 构建工具,请将此行添加到构建.gradle依赖项部分下的文件:(package https://mvnrepository.com/artifact/com.microsoft.azure/azure-storage)
dependencies {
// ...
compile group: 'com.microsoft.azure', name: 'azure-storage', version: '4.0.0'
}
2) 将以下导入指令添加到您的代码中:
import com.microsoft.azure.storage.blob.CloudBlobContainer;
import com.microsoft.azure.storage.blob.CloudBlockBlob;
3)替换下面的代码块上传文件并创建资产 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);
使用以下代码块:
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();
}