Deployment via windows breaks folder paths on S3
See original GitHub issueThis 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:
- Created 5 years ago
- Comments:10 (9 by maintainers)
Top GitHub Comments
@cloudandcode maybe we can make this fix a bit more general? Something like:
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 😃
@cloudandcode and @tahir-mm this is now addressed in
v2.1.1
just pushed the new version.Thanks to @linusmarco!