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.

Deployment via windows breaks folder paths on S3

See original GitHub issue

This is a:

  • Bug report

Expected behavior

When using Windows to deploy a dist folder that contains sub-directories, the file paths should translate to folders in S3.

ie. a file in dist\js\app.js within Windows should result in app.js being placed within a ‘js’ folder in the S3 bucket so that the relative path to that file becomes /js/app.js.

Actual behavior

Using the example above, a file in dist\js\app.js is written as js\app.js within the S3 bucket and the links to that file appears as /js%5Capp.js (instead of /js/app.js) and are therefore unreachable via the expected url, resulting in 404 errors.

Steps to reproduce

Deploy a distribution directory that contains sub-directories from a Windows machine.

  • Operating system: Windows 10
  • serverless-finch version: 2.1.0

Proposed fix

Replacing the Windows file separator '' with the Posix separator ‘/’ on line 86 in /lib/upload.js does the trick for me.

fileKey: filePath.replace(clientRoot, '').replace(/\\/g, '/'),

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
linusmarcocommented, Apr 30, 2018

@cloudandcode maybe we can make this fix a bit more general? Something like:

fileKey: path.normalize(filePath.replace(clientRoot, '')).split(path.sep).join('/'),

That way it’s not a windows-only hack (that could screw things up for POSIX systems), but rather a generalized path -> AWS FileKey conversion.

EDIT: Didn’t mean to call your suggested change a “hack” in a mean-spirited way–just suggesting an improvement 😃

0reactions
fernando-mccommented, May 2, 2018

@cloudandcode and @tahir-mm this is now addressed in v2.1.1 just pushed the new version.

Thanks to @linusmarco!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sync Windows Folder with AWS S3 Bucket | JSCAPE
Learn how to configure the JSCAPE MFT Server so you can have remote Windows servers that synchronize with the Amazon S3 bucket with...
Read more >
Organizing objects in the Amazon S3 console using folders
To delete folders from an S3 bucket · In the Buckets list, choose the name of the bucket that you want to delete...
Read more >
How To Upload and Sync Files To An AWS S3 Bucket
Windows : close and reopen your command prompt to refresh the path ... Upload the folder to a subdirectory within the S3 bucket...
Read more >
Using GitHub Actions to Deploy to S3 | Alex Hyett
Recently I went through the process of setting up Drone CI on my Raspberry Pi. The plan was to use my Raspberry Pi...
Read more >
react router doesn't work in aws s3 bucket - Stack Overflow
It's because AWS S3 is looking for that folder (projects) to serve from, which you don't have. Simply point Error document to index.html...
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