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

Assets Uploaded to S3 - Path has Backslash #134

Closed
BenMenking opened this issue Nov 18, 2021 · 4 comments
Closed

Assets Uploaded to S3 - Path has Backslash #134

BenMenking opened this issue Nov 18, 2021 · 4 comments

Comments

@BenMenking
Copy link

BenMenking commented Nov 18, 2021

It appears that for any assets in subdirectories uploaded to S3, it uses a backslash instead of a forward slash. This appears to make the file(s) inaccessible. Here is the snippet I'm using in serverless.yml:

constructs:
  website:
    type: server-side-website
    assets:
      '/js/*': assets/js
      '/css/*': assets/css
      '/images/*': assets/images
      '/favicon.ico': assets/favicon.ico
      '/robots.txt': assets/robots.txt
    domain: ${self:custom.domains.${self:custom.stage}}
    certificate: arn:aws:acm:us-east-1:xxxxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Here's a sample of those files as they appear in S3 (retrieved via aws s3 ls <bucket>; displays same way in AWS console):

2021-11-18 14:59:22      14631 images\logo.png
2021-11-18 14:59:22        818 images\logo1.png
2021-11-18 14:59:22       1000 images\logo2.png
2021-11-18 14:59:23       1396 images\logo3.png
2021-11-18 18:43:50       1459 images\logo4.png
2021-11-18 14:59:23       3216 images\logo5.png

Attempting to access one of those files (https://xxxxxxxx.yyy/images/logo4.png) via CloudFront results in:

<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>images/logo4.png</Key>
<RequestId>XXXXXXXXXXXXXX</RequestId>
<HostId>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx=</HostId>
</Error>

I checked the CloudFront Behaviors section and they look correct.

If I manually delete the files in S3, create the containing directory and upload the file manually, it works as expected.

Has anyone else run into this?

@BenMenking
Copy link
Author

Ok, I'm sad to say I'm running node.js on Windows using Cygwin64. So guess which separator is going to be used in path.join() ?

Since S3 is going to use unix separators it may be prudent to use path.posix.join() instead. Going to close this issue.

@eduardo-veras
Copy link

Hi @BenMenking, I ran into the same issue on the current version (1.11.0).

I tried to search on the Lift source code, but I couldn't find where this is happening.

Is this issue a problem on the Lift code, or in another lib dependency?

@BenMenking
Copy link
Author

BenMenking commented Jan 18, 2022

@eduardo-veras A PR to fix was submitted on Nov 24, '21 and was accepted but 1.11.0 looks to be built on Nov 2nd, '21 so it won't include that fix. You could pull the latest and try that.

@eduardo-veras
Copy link

Thanks @BenMenking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants