Tabnine Logo
CloudBlob.upload
Code IndexAdd Tabnine to your IDE (free)

How to use
upload
method
in
com.microsoft.azure.storage.blob.CloudBlob

Best Java code snippets using com.microsoft.azure.storage.blob.CloudBlob.upload (Showing top 20 results out of 315)

origin: apache/nifi

blob.upload(in, length, null, null, operationContext);
BlobProperties properties = blob.getProperties();
attributes.put("azure.container", containerName);
origin: Azure/azure-storage-android

final byte[] buff = new byte[length];
randGenerator.nextBytes(buff);
blobSnapshot.upload(new ByteArrayInputStream(buff), -1);
fail("Expect an IllegalArgumentException from upload");
origin: Azure/azure-storage-android

final byte[] buff = new byte[length];
randGenerator.nextBytes(buff);
blobSnapshot.upload(new ByteArrayInputStream(buff), -1);
fail("Expect an IllegalArgumentException from upload");
origin: org.apache.hadoop/hadoop-azure

public void upload(InputStream sourceStream, OperationContext opContext)
  throws StorageException, IOException {
 getBlob().upload(sourceStream, 0, null, null, opContext);
}
origin: Azure/azure-storage-android

  final byte[] buff = new byte[length];
  randGenerator.nextBytes(buff);
  blobSnapshot.upload(new ByteArrayInputStream(buff), -1);
  fail("Expect an IllegalArgumentException from upload");
} catch (IllegalArgumentException e) {
origin: org.apache.hadoop/hadoop-azure

public void upload(InputStream sourceStream, OperationContext opContext)
  throws StorageException, IOException {
 getBlob().upload(sourceStream, 0, null, null, opContext);
}
origin: org.apache.hadoop/hadoop-azure

public void upload(InputStream sourceStream, OperationContext opContext)
  throws StorageException, IOException {
 getBlob().upload(sourceStream, 0, null, null, opContext);
}
origin: org.apache.hadoop/hadoop-azure

public void upload(InputStream sourceStream, OperationContext opContext)
  throws StorageException, IOException {
 getBlob().upload(sourceStream, 0, null, null, opContext);
}
origin: Azure/azure-storage-android

  throws StorageException, IOException {
ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer, offset, length);
this.upload(inputStream, length, accessCondition, options, opContext);
inputStream.close();
origin: com.microsoft.azure/azure-storage

  throws StorageException, IOException {
ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer, offset, length);
this.upload(inputStream, length, accessCondition, options, opContext);
inputStream.close();
origin: com.microsoft.azure/azure-storage

/**
 * Uploads a blob from a file. If the blob already exists on the service, it will be overwritten.
 *
 * @param path
 *            A <code>String</code> which represents the path to the file to be uploaded.
 * @param accessCondition
 *            An {@link AccessCondition} object that represents the access conditions for the blob.
 * @param options
 *            A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying
 *            <code>null</code> will use the default request options from the associated service client (
 *            {@link CloudBlobClient}).
 * @param opContext
 *            An {@link OperationContext} object that represents the context for the current operation. This object
 *            is used to track requests to the storage service, and to provide additional runtime information about
 *            the operation.
 *
 * @throws StorageException
 *             If a storage service error occurred.
 * @throws IOException
 */
public void uploadFromFile(final String path, final AccessCondition accessCondition, BlobRequestOptions options,
    OperationContext opContext) throws StorageException, IOException {
  File file = new File(path);
  long fileLength = file.length();
  InputStream inputStream = new FileInputStream(file); // The call to upload supports FileInputStream efficiently.
  this.upload(inputStream, fileLength, accessCondition, options, opContext);
  inputStream.close();
}
origin: Azure/azure-storage-android

/**
 * Uploads a blob from a file. If the blob already exists on the service, it will be overwritten.
 *
 * @param path
 *            A <code>String</code> which represents the path to the file to be uploaded.
 * @param accessCondition
 *            An {@link AccessCondition} object that represents the access conditions for the blob.
 * @param options
 *            A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying
 *            <code>null</code> will use the default request options from the associated service client (
 *            {@link CloudBlobClient}).
 * @param opContext
 *            An {@link OperationContext} object that represents the context for the current operation. This object
 *            is used to track requests to the storage service, and to provide additional runtime information about
 *            the operation.
 *
 * @throws StorageException
 *             If a storage service error occurred.
 * @throws IOException
 */
public void uploadFromFile(final String path, final AccessCondition accessCondition, BlobRequestOptions options,
    OperationContext opContext) throws StorageException, IOException {
  File file = new File(path);
  long fileLength = file.length();
  InputStream inputStream = new BufferedInputStream(new FileInputStream(file));
  this.upload(inputStream, fileLength, accessCondition, options, opContext);
  inputStream.close();
}
origin: Azure/azure-storage-android

protected static void doDownloadRangeToByteArrayTest(CloudBlob blob, int blobSize, int bufferSize,
    int bufferOffset, Long blobOffset, Long length) throws IOException, StorageException {
  final Random randGenerator = new Random();
  final byte[] buffer = new byte[blobSize];
  randGenerator.nextBytes(buffer);
  byte[] resultBuffer = new byte[bufferSize];
  int downloadLength;
  BlobRequestOptions options = new BlobRequestOptions();
  blob.upload(new ByteArrayInputStream(buffer), buffer.length);
  downloadLength = blob.downloadRangeToByteArray(blobOffset, length, resultBuffer, bufferOffset, null, options,
      null);
  int downloadSize = Math.min(blobSize - (int) (blobOffset != null ? blobOffset : 0), bufferSize - bufferOffset);
  if (length != null && length < downloadSize) {
    downloadSize = length.intValue();
  }
  assertEquals(downloadSize, downloadLength);
  for (int i = 0; i < bufferOffset; i++) {
    assertEquals(0, resultBuffer[i]);
  }
  for (int j = 0; j < downloadLength; j++) {
    assertEquals(buffer[(int) ((blobOffset != null ? blobOffset : 0) + j)], resultBuffer[bufferOffset
        + j]);
  }
  for (int k = bufferOffset + downloadLength; k < bufferSize; k++) {
    assertEquals(0, resultBuffer[k]);
  }
}
origin: Azure/azure-storage-android

protected static void doDownloadTest(CloudBlob blob, int blobSize, int bufferSize, int bufferOffset)
    throws StorageException, IOException {
  final Random randGenerator = new Random();
  final byte[] buffer = new byte[blobSize];
  randGenerator.nextBytes(buffer);
  byte[] resultBuffer = new byte[bufferSize];
  BlobRequestOptions options = new BlobRequestOptions();
  if (blob.getClass() == CloudBlockBlob.class) {
    options.setUseTransactionalContentMD5(true);
  }
  blob.upload(new ByteArrayInputStream(buffer), buffer.length);
  blob.downloadToByteArray(resultBuffer, bufferOffset, null, options, null);
  for (int i = 0; i < blob.getProperties().getLength(); i++) {
    assertEquals(buffer[i], resultBuffer[bufferOffset + i]);
  }
  if (bufferOffset + blobSize < bufferSize) {
    for (int k = bufferOffset + blobSize; k < bufferSize; k++) {
      assertEquals(0, resultBuffer[k]);
    }
  }
}
origin: Microsoft/azure-tools-for-java

@NotNull
public BlobFile createBlobFile(@NotNull ClientStorageAccount storageAccount,
                @NotNull BlobDirectory parentBlobDirectory,
                @NotNull BlobFile blobFile)
    throws AzureCmdException {
  try {
    CloudBlobClient client = getCloudBlobClient(storageAccount);
    String containerName = parentBlobDirectory.getContainerName();
    CloudBlobContainer container = client.getContainerReference(containerName);
    CloudBlobDirectory parentDirectory = container.getDirectoryReference(parentBlobDirectory.getPath());
    CloudBlob blob = getCloudBlob(parentDirectory, blobFile);
    blob.upload(new ByteArrayInputStream(new byte[0]), 0);
    return reloadBlob(blob, containerName, blobFile);
  } catch (Throwable t) {
    throw new AzureCmdException("Error creating the Blob File", t);
  }
}
origin: Azure/azure-storage-android

case BLOCK_BLOB:
  blob = container.getBlockBlobReference(name);
  blob.upload(getRandomDataStream(length), length, null, null, context);
  break;
    ((CloudPageBlob) blob).create(length, null, null, context);
  } else {
    blob.upload(getRandomDataStream(length), length, null, null, context);
    ((CloudAppendBlob) blob).createOrReplace(null, null, context);
  } else {
    blob.upload(getRandomDataStream(length), length, null, null, context);
origin: Azure/azure-storage-android

@Test
public void testBlobLeaseAcquireAndRelease() throws URISyntaxException, StorageException, IOException {
  final int length = 128;
  final CloudBlob blobRef = BlobTestHelper.uploadNewBlob(this.container, BlobType.BLOCK_BLOB, "test", 128, null);
  // Get Lease 
  OperationContext operationContext = new OperationContext();
  final String leaseID = blobRef.acquireLease(15, null /*proposed lease id */, null /*access condition*/,
      null/* BlobRequestOptions */, operationContext);
  final AccessCondition leaseCondition = AccessCondition.generateLeaseCondition(leaseID);
  assertTrue(operationContext.getLastResult().getStatusCode() == HttpURLConnection.HTTP_CREATED);
  tryUploadWithBadLease(length, blobRef, null, StorageErrorCodeStrings.LEASE_ID_MISSING);
  // Try to upload with lease
  blobRef.upload(BlobTestHelper.getRandomDataStream(length), -1, leaseCondition, null, null);
  // Release lease
  blobRef.releaseLease(leaseCondition);
  // now upload with no lease specified.
  blobRef.upload(BlobTestHelper.getRandomDataStream(length), -1);
}
origin: Azure/azure-storage-android

/**
 * Try to upload with a bad lease
 * 
 * @param length
 * @param blobRef
 * @throws IOException
 */
private void tryUploadWithBadLease(final int length, final CloudBlob blobRef, final AccessCondition leaseCondition,
    final String expectedError) throws IOException {
  try {
    blobRef.upload(BlobTestHelper.getRandomDataStream(length), -1, leaseCondition, null, null);
    fail("Did not throw expected exception");
  }
  catch (final StorageException ex) {
    assertEquals(ex.getHttpStatusCode(), 412);
    assertEquals(ex.getErrorCode(), expectedError);
  }
}
origin: Azure/azure-storage-android

byte[] resultBuffer = new byte[resultBufSize];
blob.upload(new ByteArrayInputStream(buffer), buffer.length);
origin: Azure/azure-storage-android

blobRef.upload(BlobTestHelper.getRandomDataStream(length), -1, leaseCondition1, null, null);
blobRef.upload(BlobTestHelper.getRandomDataStream(length), -1, leaseCondition2, null, null);
com.microsoft.azure.storage.blobCloudBlobupload

Javadoc

Uploads the source stream data to the blob. If the blob already exists on the service, it will be overwritten.

Popular methods of CloudBlob

  • getName
    Returns the name of the blob.
  • deleteIfExists
    Deletes the blob if it exists, using the specified snapshot and request options, and operation conte
  • download
    Downloads the contents of a blob to a stream using the specified request options and operation conte
  • getProperties
    Returns the blob's properties.
  • downloadAttributes
    Populates a blob's properties and metadata using the specified request options and operation context
  • getUri
    Returns the URI for this blob.
  • getMetadata
    Returns the metadata for the blob.
  • delete
    Deletes the blob using the specified snapshot and request options, and operation context. If a delet
  • acquireLease
    Acquires a new lease on the blob with the specified lease time, proposed lease ID, request options,
  • openInputStream
    Opens a blob input stream to download the blob using the specified request options and operation con
  • releaseLease
    Releases the lease on the blob using the specified request options and operation context.
  • setMetadata
    Sets the metadata for the blob.
  • releaseLease,
  • setMetadata,
  • uploadMetadata,
  • downloadToByteArray,
  • exists,
  • startCopy,
  • uploadProperties,
  • downloadRange,
  • downloadRangeToByteArray

Popular in Java

  • Updating database using SQL prepared statement
  • getSystemService (Context)
  • setContentView (Activity)
  • onCreateOptionsMenu (Activity)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now