Skip to content
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

colon in S3 path is invalid for Windows file path #3215

Closed
gaochenyue opened this issue Jan 19, 2020 · 2 comments
Closed

colon in S3 path is invalid for Windows file path #3215

gaochenyue opened this issue Jan 19, 2020 · 2 comments
Assignees
Labels
mock Issues tied to the mock functionality pending-triage Issue is pending triage

Comments

@gaochenyue
Copy link

gaochenyue commented Jan 19, 2020

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the
Amplify Console GitHub Issue Tracker

Describe the bug
For the S3 mock on Windows, the S3 file path of a private put has a colon, e.g us-west-2:e2b2fdb8-38b8-4e47-8594-316a20dea577, which is an invalid character for Windows file path. When put a file with private level, it failed with the error below

(node:9360) UnhandledPromiseRejectionWarning: Error: E:\webWokrspace\programs\app\amplify\mock-data\S3\app\private\us-west-2:e2b2fdb8-38b8-4e47-8594-316a20dea577\labelx\2019 contains invalid WIN32 path characters.
    at Object.mkdirsSync (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:18:22)
    at Object.createFileSync (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\fs-extra\lib\ensure\file.js:40:11)
    at StorageServer.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-storage-simulator\src\server\S3server.ts:212:5)
    at Generator.next (<anonymous>)
    at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-storage-simulator\lib\server\S3server.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-storage-simulator\lib\server\S3server.js:4:12)
    at StorageServer.handleRequestPut (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-storage-simulator\lib\server\S3server.js:195:16)
    at StorageServer.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-storage-simulator\src\server\S3server.ts:90:12)
    at Generator.next (<anonymous>)
(node:9360) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9360) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Amplify CLI Version
4.12.0
To Reproduce
Run the following code in mock mode

Storage.put(s3Key, xlsxFile, {
        level: "private",
        contentType: "application/octet-stream"
    });

Expected behavior
The file can be save succefully

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows
  • Node Version. 10

Additional context
Add any other context about the problem here.

@SwaySway SwaySway added mock Issues tied to the mock functionality pending-triage Issue is pending triage labels Jan 21, 2020
@SimonLegg
Copy link

Just as a note: any contentType will cause this. I commented on a related issue in a different repo

Angular Workaround (use environment.production)

await Storage.put(fileName, file, {
    level: environment.production ? 'private': 'public',
});
await Storage.get('myFileKey', { 
    level: environment.production ? 'private' : 'public' 
});

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
mock Issues tied to the mock functionality pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

5 participants