• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BlobOutputStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.microsoft.azure.storage.blob.BlobOutputStream的典型用法代码示例。如果您正苦于以下问题:Java BlobOutputStream类的具体用法?Java BlobOutputStream怎么用?Java BlobOutputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BlobOutputStream类属于com.microsoft.azure.storage.blob包,在下文中一共展示了BlobOutputStream类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: primeRootContainer

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
private static CloudBlockBlob primeRootContainer(CloudBlobClient blobClient,
    String accountName, String blobName, int fileSize) throws Exception {

  // Create a container if it does not exist. The container name
  // must be lower case.
  CloudBlobContainer container = blobClient.getContainerReference("https://"
      + accountName + "/" + "$root");
  container.createIfNotExists();

  // Create a blob output stream.
  CloudBlockBlob blob = container.getBlockBlobReference(blobName);
  BlobOutputStream outputStream = blob.openOutputStream();

  outputStream.write(new byte[fileSize]);
  outputStream.close();

  // Return a reference to the block blob object.
  return blob;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:AzureBlobStorageTestAccount.java


示例2: outOfBandFolder_uncleMkdirs

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
@Test
public void outOfBandFolder_uncleMkdirs() throws Exception {

  // NOTE: manual use of CloubBlockBlob targets working directory explicitly.
  // WASB driver methods prepend working directory implicitly.
  String workingDir = "user/"
      + UserGroupInformation.getCurrentUser().getShortUserName() + "/";

  CloudBlockBlob blob = testAccount.getBlobReference(workingDir
      + "testFolder1/a/input/file");
  BlobOutputStream s = blob.openOutputStream();
  s.close();
  assertTrue(fs.exists(new Path("testFolder1/a/input/file")));

  Path targetFolder = new Path("testFolder1/a/output");
  assertTrue(fs.mkdirs(targetFolder));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestOutOfBandAzureBlobOperationsLive.java


示例3: outOfBandFolder_parentDelete

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
@Test
public void outOfBandFolder_parentDelete() throws Exception {

  // NOTE: manual use of CloubBlockBlob targets working directory explicitly.
  // WASB driver methods prepend working directory implicitly.
  String workingDir = "user/"
      + UserGroupInformation.getCurrentUser().getShortUserName() + "/";
  CloudBlockBlob blob = testAccount.getBlobReference(workingDir
      + "testFolder2/a/input/file");
  BlobOutputStream s = blob.openOutputStream();
  s.close();
  assertTrue(fs.exists(new Path("testFolder2/a/input/file")));

  Path targetFolder = new Path("testFolder2/a/input");
  assertTrue(fs.delete(targetFolder, true));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestOutOfBandAzureBlobOperationsLive.java


示例4: outOfBandFolder_siblingCreate

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
@Test
public void outOfBandFolder_siblingCreate() throws Exception {

  // NOTE: manual use of CloubBlockBlob targets working directory explicitly.
  // WASB driver methods prepend working directory implicitly.
  String workingDir = "user/"
      + UserGroupInformation.getCurrentUser().getShortUserName() + "/";
  CloudBlockBlob blob = testAccount.getBlobReference(workingDir
      + "testFolder3/a/input/file");
  BlobOutputStream s = blob.openOutputStream();
  s.close();
  assertTrue(fs.exists(new Path("testFolder3/a/input/file")));

  Path targetFile = new Path("testFolder3/a/input/file2");
  FSDataOutputStream s2 = fs.create(targetFile);
  s2.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestOutOfBandAzureBlobOperationsLive.java


示例5: outOfBandFolder_rename

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
@Test
public void outOfBandFolder_rename() throws Exception {

  // NOTE: manual use of CloubBlockBlob targets working directory explicitly.
  // WASB driver methods prepend working directory implicitly.
  String workingDir = "user/"
      + UserGroupInformation.getCurrentUser().getShortUserName() + "/";
  CloudBlockBlob blob = testAccount.getBlobReference(workingDir
      + "testFolder4/a/input/file");
  BlobOutputStream s = blob.openOutputStream();
  s.close();

  Path srcFilePath = new Path("testFolder4/a/input/file");
  assertTrue(fs.exists(srcFilePath));

  Path destFilePath = new Path("testFolder4/a/input/file2");
  fs.rename(srcFilePath, destFilePath);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestOutOfBandAzureBlobOperationsLive.java


示例6: outOfBandSingleFile_rename

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
@Test
public void outOfBandSingleFile_rename() throws Exception {

  //NOTE: manual use of CloubBlockBlob targets working directory explicitly.
  //       WASB driver methods prepend working directory implicitly.
  String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/";
  CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder5/a/input/file");
  BlobOutputStream s = blob.openOutputStream();
  s.close();

  Path srcFilePath = new Path("testFolder5/a/input/file");
  assertTrue(fs.exists(srcFilePath));

  Path destFilePath = new Path("testFolder5/file2");
  fs.rename(srcFilePath, destFilePath);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestOutOfBandAzureBlobOperationsLive.java


示例7: testContainerExistAfterDoesNotExist

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
@Test
public void testContainerExistAfterDoesNotExist() throws Exception {
  testAccount = AzureBlobStorageTestAccount.create("",
      EnumSet.noneOf(CreateOptions.class));
  assumeNotNull(testAccount);
  CloudBlobContainer container = testAccount.getRealContainer();
  FileSystem fs = testAccount.getFileSystem();

  // Starting off with the container not there
  assertFalse(container.exists());

  // A list shouldn't create the container and will set file system store
  // state to DoesNotExist
  try {
    fs.listStatus(new Path("/"));
    assertTrue("Should've thrown.", false);
  } catch (FileNotFoundException ex) {
    assertTrue("Unexpected exception: " + ex,
        ex.getMessage().contains("does not exist."));
  }
  assertFalse(container.exists());

  // Create a container outside of the WASB FileSystem
  container.create();
  // Add a file to the container outside of the WASB FileSystem
  CloudBlockBlob blob = testAccount.getBlobReference("foo");
  BlobOutputStream outputStream = blob.openOutputStream();
  outputStream.write(new byte[10]);
  outputStream.close();

  // Make sure the file is visible
  assertTrue(fs.exists(new Path("/foo")));
  assertTrue(container.exists());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:TestContainerChecks.java


示例8: outOfBandFolder_rootFileDelete

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
@Test
public void outOfBandFolder_rootFileDelete() throws Exception {

  CloudBlockBlob blob = testAccount.getBlobReference("fileY");
  BlobOutputStream s = blob.openOutputStream();
  s.close();
  assertTrue(fs.exists(new Path("/fileY")));
  assertTrue(fs.delete(new Path("/fileY"), true));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TestOutOfBandAzureBlobOperationsLive.java


示例9: outOfBandFolder_firstLevelFolderDelete

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
@Test
public void outOfBandFolder_firstLevelFolderDelete() throws Exception {

  CloudBlockBlob blob = testAccount.getBlobReference("folderW/file");
  BlobOutputStream s = blob.openOutputStream();
  s.close();
  assertTrue(fs.exists(new Path("/folderW")));
  assertTrue(fs.exists(new Path("/folderW/file")));
  assertTrue(fs.delete(new Path("/folderW"), true));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestOutOfBandAzureBlobOperationsLive.java


示例10: outOfBandFolder_rename_rootLevelFiles

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
@Test
public void outOfBandFolder_rename_rootLevelFiles() throws Exception {

  // NOTE: manual use of CloubBlockBlob targets working directory explicitly.
  // WASB driver methods prepend working directory implicitly.
  CloudBlockBlob blob = testAccount.getBlobReference("fileX");
  BlobOutputStream s = blob.openOutputStream();
  s.close();

  Path srcFilePath = new Path("/fileX");
  assertTrue(fs.exists(srcFilePath));

  Path destFilePath = new Path("/fileXrename");
  fs.rename(srcFilePath, destFilePath);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:TestOutOfBandAzureBlobOperationsLive.java


示例11: primePublicContainer

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
public static void primePublicContainer(CloudBlobClient blobClient,
    String accountName, String containerName, String blobName, int fileSize)
    throws Exception {

  // Create a container if it does not exist. The container name
  // must be lower case.
  CloudBlobContainer container = blobClient
      .getContainerReference(containerName);

  container.createIfNotExists();

  // Create a new shared access policy.
  SharedAccessBlobPolicy sasPolicy = new SharedAccessBlobPolicy();

  // Set READ and WRITE permissions.
  //
  sasPolicy.setPermissions(EnumSet.of(
      SharedAccessBlobPermissions.READ,
      SharedAccessBlobPermissions.WRITE,
      SharedAccessBlobPermissions.LIST,
      SharedAccessBlobPermissions.DELETE));

  // Create the container permissions.
  BlobContainerPermissions containerPermissions = new BlobContainerPermissions();

  // Turn public access to the container off.
  containerPermissions
      .setPublicAccess(BlobContainerPublicAccessType.CONTAINER);

  // Set the policy using the values set above.
  containerPermissions.getSharedAccessPolicies().put("testwasbpolicy",
      sasPolicy);
  container.uploadPermissions(containerPermissions);

  // Create a blob output stream.
  CloudBlockBlob blob = container.getBlockBlobReference(blobName);
  BlobOutputStream outputStream = blob.openOutputStream();

  outputStream.write(new byte[fileSize]);
  outputStream.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:42,代码来源:AzureBlobStorageTestAccount.java


示例12: testReadTimeoutIssue

import com.microsoft.azure.storage.blob.BlobOutputStream; //导入依赖的package包/类
public void testReadTimeoutIssue() throws URISyntaxException, StorageException, IOException {
    // part 1
    byte[] buffer = BlobTestHelper.getRandomBuffer(1 * 1024 * 1024);

    // set the maximum execution time
    BlobRequestOptions options = new BlobRequestOptions();
    options.setMaximumExecutionTimeInMs(5000);

    CloudBlobClient blobClient = TestHelper.createCloudBlobClient();
    CloudBlobContainer container = blobClient.getContainerReference(generateRandomContainerName());

    String blobName = "testBlob";
    final CloudBlockBlob blockBlobRef = container.getBlockBlobReference(blobName);
    blockBlobRef.setStreamWriteSizeInBytes(1 * 1024 * 1024);

    ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer);
    BlobOutputStream blobOutputStream = null;

    try {
        container.createIfNotExists();
        blobOutputStream = blockBlobRef.openOutputStream(null, options, null);
        try {
            blobOutputStream.write(inputStream, buffer.length);
        } finally {
            blobOutputStream.close();
        }
        assertTrue(blockBlobRef.exists());
    } finally {
        inputStream.close();
        container.deleteIfExists();
    }

    // part 2
    int length2 = 10 * 1024 * 1024;
    byte[] uploadBuffer2 = BlobTestHelper.getRandomBuffer(length2);

    CloudBlobClient blobClient2 = TestHelper.createCloudBlobClient();
    CloudBlobContainer container2 = blobClient2.getContainerReference(generateRandomContainerName());

    String blobName2 = "testBlob";
    final CloudBlockBlob blockBlobRef2 = container2.getBlockBlobReference(blobName2);

    ByteArrayInputStream inputStream2 = new ByteArrayInputStream(uploadBuffer2);

    try {
        container2.createIfNotExists();

        blockBlobRef2.upload(inputStream2, length2);
    } finally {
        inputStream2.close();
        container2.deleteIfExists();
    }
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:54,代码来源:GenericTests.java



注:本文中的com.microsoft.azure.storage.blob.BlobOutputStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JIComServer类代码示例发布时间:2022-05-22
下一篇:
Java EntityDonkey类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap