-
Notifications
You must be signed in to change notification settings - Fork 862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TransferUtility.DownloadDirectoryAsync throws an exception under certain specific conditions #3017
Comments
My current workaround is to fix the case of the supplied destination directory path.
|
Needs reproduction. The exception is thrown at aws-sdk-net/sdk/src/Services/S3/Custom/Transfer/Internal/DownloadDirectoryCommand.cs Line 105 in 6b8562f
|
Reproducible on Windows. The issue appears to be with
We should not use Needs review with the team. @rbluff Please advise if you are unable to use |
The proposed solution could be that on Windows we could use
|
Thanks for your reply @ashishdhingra. The destination path that is passed to our |
Repro Steps:
We cannot access So the only option appears to be here is to update property documentation for Kindly note that on Windows, there is a registry setting which when set, makes file system case-sensitive (just like Linux). Refer Enabling Case Sensitivity on Windows 10 for example, which has example command |
Created PR #3509 to update the API documentation for |
@rbluff Please refer to #3017 (comment). On Windows, there is a registry setting which when set, makes file system case-sensitive (just like Linux) (refer Enabling Case Sensitivity on Windows 10 for example, which has example command
We have updated the API reference documentation for TransferUtilityDownloadDirectoryRequest.LocalDirectory mentioning that |
Comments on closed issues are hard for our team to see. |
Describe the bug
TransferUtility.DownloadDirectoryAsync(...)
throws a AmazonClientException if one of the files inside the S3 directory has a filename that contains a tilde ~ character and is in 8:3 format AND the case of the local destination directory path supplied toTransferUtilityDownloadDirectoryRequest.LocalDirectory
does not match the actual case of the directory path on the system.Expected Behavior
I expected TransferUtility.DownloadDirectoryAsync(...) to successfully download the S3 directory to the local directory without errors.
Current Behavior
Amazon.Runtime.AmazonClientException: The file C:\Windows\TEMP\abc\Imports\01_4791\Job52\files\Audio\vc~ended.caf is not allowed outside of the target directory C:\Windows\TEMP\abc\Imports\01_4791\Job52.\r\n at Amazon.S3.Transfer.Internal.DownloadDirectoryCommand.ConstructTransferUtilityDownloadRequest(S3Object s3Object, Int32 prefixLength) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Services\S3\Custom\Transfer\Internal\DownloadDirectoryCommand.cs:line 105\r\n at Amazon.S3.Transfer.Internal.DownloadDirectoryCommand.d__22.MoveNext() in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Services\S3\Custom\Transfer\Internal\_bcl45+netstandard\DownloadDirectoryCommand.cs:line 105\r\n--- End of stack trace from previous location where exception was thrown ---
Note that the filename of the file in S3 (
vc~ended.caf
) contains 8 characters in the filename and 3 characters in the extension, and also contains a tilde~
character.The directory path supplied to
TransferUtilityDownloadDirectoryRequest.LocalDirectory
wasC:\Windows\TEMP\abc\Imports\01_4791\Job52
but the actual case of the temp folder on the system isC:\Windows\Temp
. ie. the supplied path containedTEMP
but the actual path on the system wasTemp
.Reproduction Steps
The key requirements to reproduce the bug are:
sourceDirectoryKey
must contain a file with a filename in 8:3 format, and with a tilde character in the filename. eg.vc~ended.caf
ortm~tilde.tmp
destinationDirectoryPath
should have a case that is different to the actual case of the directory path on the system. For example, you could calldestinationDirectoryPath.ToLowerInvariant()
to achieve this.Possible Solution
DownloadDirectoryCommand.ConstructTransferUtilityDownloadRequest(...)
contains the following checkand the source of the
IsFilePathRootedWithDirectoryPath
method is as follows:If
filePath
refers to a file with a filename in 8:3 format and that contains a tilde character, thenFileInfo(filePath).FullName
will contain the path with the correct case of the directory on the system, even iffilePath
contains a path with the incorrect case.eg.
new FileInfo(@"C:\Windows\TEMP\vc~ended.caf").FullName
will returnC:\Windows\Temp\vc~ended.caf
ifC:\Windows\Temp
is the correct case of the directory path.Instead of
return new FileInfo(filePath).FullName.StartsWith(directoryInfo.FullName);
you could usereturn new FileInfo(filePath).FullName.StartsWith(directoryInfo.FullName, StringComparison.InvariantCultureIgnoreCase);
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.S3 3.7.106.1
Targeted .NET Platform
.NET Standard 2.0
Operating System and version
Windows 10, Windows Server 2019
The text was updated successfully, but these errors were encountered: