/** * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the container, using the * specified snapshot ID. * * @param blobName * A <code>String</code> that represents the name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the blob. * * @return A {@link CloudPageBlob} object that represents a reference to the specified page blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudPageBlob getPageBlobReference(final String blobName, final String snapshotID) throws URISyntaxException, StorageException { return new CloudPageBlob(blobName, snapshotID, this); }
/** * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the container, using the * specified snapshot ID. * * @param blobName * A <code>String</code> that represents the name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the blob. * * @return A {@link CloudPageBlob} object that represents a reference to the specified page blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudPageBlob getPageBlobReference(final String blobName, final String snapshotID) throws URISyntaxException, StorageException { return new CloudPageBlob(blobName, snapshotID, this); }
public static CloudPageBlob createPageBlobClient(BlobServiceConfiguration cfg) throws Exception { CloudPageBlob client = (CloudPageBlob) getConfiguredClient(cfg); if (client == null) { URI uri = prepareStorageBlobUri(cfg); StorageCredentials creds = getAccountCredentials(cfg); client = new CloudPageBlob(uri, creds); } return client; }
/** * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the directory, using the * specified snapshot ID. * * @param blobName * A <code>String</code> that represents the name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the blob. * * @return A {@link CloudPageBlob} object that represents a reference to the specified page blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudPageBlob getPageBlobReference(final String blobName, final String snapshotID) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("blobName", blobName); return new CloudPageBlob(this.getPrefix().concat(blobName), snapshotID, this.getContainer()); }
/** * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the directory, using the * specified snapshot ID. * * @param blobName * A <code>String</code> that represents the name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the blob. * * @return A {@link CloudPageBlob} object that represents a reference to the specified page blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudPageBlob getPageBlobReference(final String blobName, final String snapshotID) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("blobName", blobName); return new CloudPageBlob(this.getPrefix().concat(blobName), snapshotID, this.getContainer()); }
@Override public CloudBlobWrapper getPageBlobReference(String relativePath) throws URISyntaxException, StorageException { try { CloudPageBlob blob = (sasKeyGenerator!=null) ? new CloudPageBlob(sasKeyGenerator.getRelativeBlobSASUri(storageAccount, getName(), relativePath)) : container.getPageBlobReference(relativePath); blob.getServiceClient().setDefaultRequestOptions( container.getServiceClient().getDefaultRequestOptions()); return new SASCloudPageBlobWrapperImpl(blob); } catch (SASKeyGenerationException sasEx) { String errorMsg = "Encountered SASKeyGeneration exception while " + "generating SAS Key for relativePath : " + relativePath + " inside container : " + getName() + " Storage account : " + storageAccount; LOG.error(errorMsg); throw new StorageException(SAS_ERROR_CODE, errorMsg, sasEx); } } }
public static CloudPageBlob defiddler(CloudPageBlob blob) throws URISyntaxException, StorageException { URI oldUri = blob.getUri(); URI newUri = defiddler(oldUri); if (newUri != oldUri) { CloudPageBlob newBlob = new CloudPageBlob(newUri, blob.getServiceClient().getCredentials()); newBlob.setSnapshotID(blob.snapshotID); return newBlob; } else { return blob; } }
public static CloudBlob getBlobReference(BlobType type, StorageCredentials credentials, URI uri) throws StorageException, URISyntaxException { CloudBlob blob = null; switch (type) { case APPEND_BLOB: blob = new CloudAppendBlob(credentials.transformUri(uri)); break; case BLOCK_BLOB: blob = new CloudBlockBlob(credentials.transformUri(uri)); break; case PAGE_BLOB: blob = new CloudPageBlob(credentials.transformUri(uri)); break; case UNSPECIFIED: fail(); } return blob; }
@Override public CloudBlob preProcessResponse(CloudBlob blob, CloudBlobClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); return null; } CloudBlob snapshot = null; final String snapshotTime = BlobResponse.getSnapshotTime(this.getConnection()); if (blob instanceof CloudBlockBlob) { snapshot = new CloudBlockBlob(blob.getName(), snapshotTime, CloudBlob.this.getContainer()); } else if (blob instanceof CloudPageBlob) { snapshot = new CloudPageBlob(blob.getName(), snapshotTime, CloudBlob.this.getContainer()); } else if (blob instanceof CloudAppendBlob) { snapshot = new CloudAppendBlob(blob.getName(), snapshotTime, CloudBlob.this.getContainer()); } snapshot.setProperties(blob.properties); // use the specified metadata if not null : otherwise blob's metadata snapshot.setMetadata(metadata != null ? metadata : blob.metadata); snapshot.updateEtagAndLastModifiedFromResponse(this.getConnection()); return snapshot; } };
@Override public CloudBlob preProcessResponse(CloudBlob blob, CloudBlobClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); return null; } CloudBlob snapshot = null; final String snapshotTime = BlobResponse.getSnapshotTime(this.getConnection()); if (blob instanceof CloudBlockBlob) { snapshot = new CloudBlockBlob(blob.getName(), snapshotTime, CloudBlob.this.getContainer()); } else if (blob instanceof CloudPageBlob) { snapshot = new CloudPageBlob(blob.getName(), snapshotTime, CloudBlob.this.getContainer()); } else if (blob instanceof CloudAppendBlob) { snapshot = new CloudAppendBlob(blob.getName(), snapshotTime, CloudBlob.this.getContainer()); } snapshot.setProperties(blob.properties); // use the specified metadata if not null : otherwise blob's metadata snapshot.setMetadata(metadata != null ? metadata : blob.metadata); snapshot.updateEtagAndLastModifiedFromResponse(this.getConnection()); return snapshot; } };
CloudPageBlob copySas = new CloudPageBlob(new URI(copy.getUri().toString() + "?" + sasToken));
assertEquals(endpoint, pageBlob.getServiceClient().getStorageUri()); pageBlob = new CloudPageBlob(blobUri, client.getCredentials()); assertEquals(blobUri, pageBlob.getStorageUri()); assertEquals(blobUri.getPrimaryUri(), pageBlob.getUri());