malthe commented on code in PR #6443:
URL: https://github.com/apache/nifi/pull/6443#discussion_r984699844
##########
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureBlobStorage_v12.java:
##########
@@ -121,19 +168,42 @@ public void onTrigger(final ProcessContext context, final
ProcessSession session
if (createContainer && !containerClient.exists()) {
containerClient.create();
}
+
BlobClient blobClient = containerClient.getBlobClient(blobName);
+ Relationship relationship = REL_SUCCESS;
+
+ final BlobRequestConditions blobRequestConditions = new
BlobRequestConditions();
- long length = flowFile.getSize();
+ try {
+ if (conflictStrategy ==
AzureStorageConflictStrategy.OVERWRITE_IF_SOURCE_NEWER) {
+ OffsetDateTime ifUnmodifiedSince =
OffsetDateTime.ofInstant(
+ Instant.ofEpochMilli(flowFile.getEntryDate()),
+ ZoneId.systemDefault()
+ );
+
blobRequestConditions.setIfUnmodifiedSince(ifUnmodifiedSince);
+ } else if (conflictStrategy !=
AzureStorageConflictStrategy.OVERWRITE) {
+ blobRequestConditions.setIfNoneMatch("*");
+ }
- try (InputStream rawIn = session.read(flowFile);
- BufferedInputStream bufferedIn = new
BufferedInputStream(rawIn)) {
- blobClient.upload(bufferedIn, length);
+ try (InputStream rawIn = session.read(flowFile)) {
+ final BlobParallelUploadOptions blobParallelUploadOptions
= new BlobParallelUploadOptions(toFluxByteBuffer(rawIn));
+
blobParallelUploadOptions.setRequestConditions(blobRequestConditions);
+ blobClient.uploadWithResponse(blobParallelUploadOptions,
null, Context.NONE);
Review Comment:
I can perhaps talk a little bit about `OVERWRITE_IF_SOURCE_NEWER` – it's
because I have a follow-up PR more or less ready which adds functionality to
this processor to copy not from the flow file content, but from another blob
(possibly in another storage account) using the [Put Blob From
URL](https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob-from-url)
service call.
See https://issues.apache.org/jira/browse/NIFI-9972.
This option is also supported by azcopy, the reason being that it's
supported directly by the service such that it's able to conditionally check
this before processing the request.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]