jfrazee commented on a change in pull request #5098:
URL: https://github.com/apache/nifi/pull/5098#discussion_r675242859



##########
File path: 
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java
##########
@@ -114,30 +119,23 @@ public void onTrigger(final ProcessContext context, final 
ProcessSession session
             final DataLakeServiceClient storageClient = 
getStorageClient(context, flowFile);
             final DataLakeFileSystemClient fileSystemClient = 
storageClient.getFileSystemClient(fileSystem);
             final DataLakeDirectoryClient directoryClient = 
fileSystemClient.getDirectoryClient(directory);
-            final DataLakeFileClient fileClient;
+            DataLakeFileClient fileClient;
 
             final String conflictResolution = 
context.getProperty(CONFLICT_RESOLUTION).getValue();
             boolean overwrite = conflictResolution.equals(REPLACE_RESOLUTION);
+            final String tempFilePrefix = 
defaultIfBlank(System.getProperty("tempFilePrefix"), TEMP_FILE_PREFIX);
 
             try {
-                fileClient = directoryClient.createFile(fileName, overwrite);
-
-                final long length = flowFile.getSize();
-                if (length > 0) {
-                    try (final InputStream rawIn = session.read(flowFile); 
final BufferedInputStream bufferedIn = new BufferedInputStream(rawIn)) {
-                        uploadContent(fileClient, bufferedIn, length);
-                    } catch (Exception e) {
-                        removeTempFile(fileClient);
-                        throw e;
-                    }
-                }
+                fileClient = directoryClient.createFile(tempFilePrefix + 
fileName, true);

Review comment:
       Updating my comment here. A random prefix will be preferable to a random 
suffix, and given that conflicting names can lead to problems we probably 
shouldn't give absolute control to the user. We should do something like the 
following (which is loosely based on the approach in Hadoop):
   
   ```java
   // The temp files should be tucked away in a directory because of the impact
   // they could have on file listings. Hadoop uses "_$azuretmpfolder$" 
statically
   // but I think it could be useful to be configurable. The default should be
   // prefaced with . or _ though.
   final String tempFileFolder = 
context.getProperty(TEMP_FILE_FOLDER).getValue();
   
   final String tempFilePrefix = tempFileFolder + "/" + 
UUID.randomUUID().toString();
   final String tempFilePath = tempFilePrefix + fileName;
   ```




-- 
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]


Reply via email to