question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] DataLakeFileClient Upload / UploadAsync fail on readonly files

See original GitHub issue

Describe the bug There are 3 places in DataLakeFileClient where a FileStream is created with unnecessary write access (implicit by the latter’s ctor): https://github.com/Azure/azure-sdk-for-net/blob/322f6952e4946229949bd3375f5eb6120895fd2f/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs#L3111 https://github.com/Azure/azure-sdk-for-net/blob/322f6952e4946229949bd3375f5eb6120895fd2f/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs#L3227 https://github.com/Azure/azure-sdk-for-net/blob/322f6952e4946229949bd3375f5eb6120895fd2f/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs#L3439

This will cause failures when trying to upload readonly files.

Windows sample stack trace:

System.UnauthorizedAccessException: Access to the path 'C:\foo.rnd' is denied.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   at Azure.Storage.Files.DataLake.DataLakeFileClient.UploadAsync(String path, PathHttpHeaders httpHeaders, DataLakeRequestConditions conditions, IProgress`1 progressHandler, StorageTransferOptions transferOptions, CancellationToken cancellationToken)

OSX sample stack trace:

System.UnauthorizedAccessException: Access to the path '/Users/johndoe/foo.bar' is denied.
 ---> System.IO.IOException: Operation not permitted
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Azure.Storage.Files.DataLake.DataLakeFileClient.UploadAsync(String path, PathHttpHeaders httpHeaders, DataLakeRequestConditions conditions, IProgress`1 progressHandler, StorageTransferOptions transferOptions, CancellationToken cancellationToken)
   at Microsoft.Azure.DashCamUploader.DataLakeUploader.Upload(String file) in 

To Reproduce Call one of the DataLakeFileClient::UploadAsync/DataLakeFileClient::Upload overrides which accepts a file name (string)

Workaround Use one of the DataLakeFileClient::UploadAsync/DataLakeFileClient::Upload overrides accepting a Stream, and pass it File.OpenRead(path)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
seanmcc-msftcommented, Sep 2, 2020

Hi @ohadschn, thanks for the detailed bug report. I’ll work to get this fixed in our next release.

-Sean

1reaction
jsquirecommented, Aug 27, 2020

Thank you for your feedback. Tagging and routing to the team best able to assist.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DataLakeFileClient.UploadAsync Method - Storage
The UploadAsync(Stream, Boolean, CancellationToken) operation creates and uploads content to a file. If the file already exists, then its content will not ...
Read more >
Overwrite a blob on Blob Storage - getting "read only" ...
I use this code, where blob_url contains the SAS token. The blob has access level "private". However, I always get this error: Result:...
Read more >
[Solved]-How to set ContentMD5 in DataLakeFileClient?-C#
I have found the solution. The UploadAsync method has an overload that accepts a parameter of type DataLakeFileUploadOptions.
Read more >
Dos and Don'ts for Streaming File Uploads to Azure Blob ...
Implement file uploads the wrong way, and you may end up with memory leaks, server slowdowns, out-of-memory errors, and worst of all, unhappy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found