BlobClient.uploadFromFile Method

Definition

Overloads

uploadFromFile(String filePath)

Creates a new block blob. By default this method will not overwrite an existing blob.

Code Samples

try {
     client.uploadFromFile(filePath);
     System.out.println("Upload from file succeeded");
 } catch (UncheckedIOException ex) {
     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
 }
uploadFromFile(String filePath, boolean overwrite)

Creates a new block blob, or updates the content of an existing block blob.

Code Samples

try {
     boolean overwrite = false;
     client.uploadFromFile(filePath, overwrite);
     System.out.println("Upload from file succeeded");
 } catch (UncheckedIOException ex) {
     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
 }
uploadFromFile(String filePath, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map<String,String> metadata, AccessTier tier, BlobRequestConditions requestConditions, Duration timeout)

Creates a new block blob, or updates the content of an existing block blob.

To avoid overwriting, pass "*" to setIfNoneMatch(String ifNoneMatch).

Code Samples

BlobHttpHeaders headers = new BlobHttpHeaders()
     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
     .setContentLanguage("en-US")
     .setContentType("binary");
 
 Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 BlobRequestConditions requestConditions = new BlobRequestConditions()
     .setLeaseId(leaseId)
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
 Long blockSize = 100L * 1024L * 1024L; // 100 MB;
 ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize);
 
 try {
     client.uploadFromFile(filePath, parallelTransferOptions, headers, metadata,
         AccessTier.HOT, requestConditions, timeout);
     System.out.println("Upload from file succeeded");
 } catch (UncheckedIOException ex) {
     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
 }

uploadFromFile(String filePath)

Creates a new block blob. By default this method will not overwrite an existing blob.

Code Samples

try {
     client.uploadFromFile(filePath);
     System.out.println("Upload from file succeeded");
 } catch (UncheckedIOException ex) {
     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
 }
public void uploadFromFile(String filePath)

Parameters

filePath
java.lang.String

Path of the file to upload

uploadFromFile(String filePath, boolean overwrite)

Creates a new block blob, or updates the content of an existing block blob.

Code Samples

try {
     boolean overwrite = false;
     client.uploadFromFile(filePath, overwrite);
     System.out.println("Upload from file succeeded");
 } catch (UncheckedIOException ex) {
     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
 }
public void uploadFromFile(String filePath, boolean overwrite)

Parameters

filePath
java.lang.String

Path of the file to upload

overwrite
boolean

Whether or not to overwrite, should the blob already exist

uploadFromFile(String filePath, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map<String,String> metadata, AccessTier tier, BlobRequestConditions requestConditions, Duration timeout)

Creates a new block blob, or updates the content of an existing block blob.

To avoid overwriting, pass "*" to setIfNoneMatch(String ifNoneMatch).

Code Samples

BlobHttpHeaders headers = new BlobHttpHeaders()
     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
     .setContentLanguage("en-US")
     .setContentType("binary");
 
 Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 BlobRequestConditions requestConditions = new BlobRequestConditions()
     .setLeaseId(leaseId)
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
 Long blockSize = 100L * 1024L * 1024L; // 100 MB;
 ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize);
 
 try {
     client.uploadFromFile(filePath, parallelTransferOptions, headers, metadata,
         AccessTier.HOT, requestConditions, timeout);
     System.out.println("Upload from file succeeded");
 } catch (UncheckedIOException ex) {
     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
 }
public void uploadFromFile(String filePath, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map<String,String> metadata, AccessTier tier, BlobRequestConditions requestConditions, Duration timeout)

Parameters

filePath
java.lang.String

Path of the file to upload

parallelTransferOptions
ParallelTransferOptions

ParallelTransferOptions to use to upload from file. Number of parallel transfers parameter is ignored.

metadata
java.util.Map<java.lang.String,java.lang.String>

Metadata to associate with the blob. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.

tier
AccessTier

AccessTier for the uploaded blob

timeout
java.time.Duration

An optional timeout value beyond which a RuntimeException will be raised.

Applies to