-
Notifications
You must be signed in to change notification settings - Fork 14
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
Unknown field localFile on type S3Image #8
Comments
My guess is that there aren't any images in the s3 bucket. If you open up graphiql, e.g. query {
allS3Image {
edges {
node {
id
}
}
}
} do you see any results? |
Also if it helps, here's a working example of this plugin. Admittedly, I haven't tested it much with Gatsby v2! https://github.com/DSchau/photos.maggieanddustin.com |
Thanks for your quick response! Running the above query works fine, and in fact I can display unprocessed S3 images via the Could this be related to the way I'll take a look at the working example you shared 👍 |
Would this regular expression match the types of images in your S3 bucket? |
@DSchau I think so - the following query retrieved node
If you don't mind pointing it out - where is the image processing part hooked into the plugin? Is it via the |
Yup! I believe that creates that localFile graphql resolver. Most helpful here would be a repo reproducing the issue! |
Here's an example repo. It's got read-only AWS creds in The index page shows the
Let me know if this helps! Thanks |
It will! Thanks so much! I'll take a look at this in a few! |
Hey @DSchau, just checking in. I wrote above that I could display unprocessed S3 images via the Attempting to view an image via this link returns the error:
In order to source images directly from my S3 bucket, I had to use a region-specific base url here ( Could my issue be related to this? Or is the availability of the |
Hey Nathan! I actually started at Gatsby on Tuesday, so I've been a little busy with that! I'm not 100% sure what the issue is yet, but I appreciate you debugging! I can try and take a look at it this weekend, sorry for the delay :( Thanks for your patience! |
Congratulations! 🎉 Ok, I'll keep poking around and share any new discoveries. Thanks for keeping in touch. |
+1 I've come across this issue pretty much exactly as @naheller has described. So far, my dependencies look like this:
If anyone can point me in the right direction (I'm new to Gatsby) that would be very helpful and appreciated! I would like to use the images in folders inside an AWS bucket and pipe them to the sharp plugin where (I guess) they would be stored locally(??) as cached images. Like @naheller I can display images from the bucket if I string replace the region-specific URL to the bucket. Then I can at least display them on the page. |
@jonathanbell still tracking on this, but see my comment above for more info! |
I just downgraded to Gatsby 1.9.247 (the same that's used in the @jonathanbell Also appears to be experiencing this issue with pre v2 Gatsby, so I suppose we can rule that out... |
Ok! After some poking around I fixed this issue, and it is indeed related to region-specific S3 bucket URLs. I cloned/linked this plugin and found that the There are two ways I found to trigger that conditional and make the
Either of these actions will expose the Since S3 bucket regions will vary between users, I feel some region-dependent URL construction in this plugin would be helpful. I'm happy to submit a PR for this if you'd like 👍 More info on path-style S3 URLs can be found here. |
Awesome job! A PR would be so welcome, and I’ll approve when I can! Ideally a test would be nice too, but this seems fairly innocuous |
@naheller Thank you! I changed my AWS bucket to N. Virginia and sure enough it worked. @DSchau I have noticed one issue. If there are spaces inside a folder name inside the S3 AWS bucket, the value of the Just thought I would point out that bug. I've changed my folder names to use hyphens instead of spaces and I can get a value (not null) from |
I think there’s some work for us to do on this 😅 Help is appreciated! Sounds like there are some edge cases here that could be ironed out! I’ll try and get to them soon, but until then, would love any and all PRs! |
Actually with my role at Gatsby, we can pair program so maybe this would be something cool to work on! Any interest? |
I ran across this problem also. My bucket is accessible via https://s3.amazonaws.com but it's not public. Since the plugin can authenticate it shows the files but createRemoteFileNode is not able to fetch them via just the url |
I've tried both of the solutions that @naheller posted above and still no luck. I was a little stumped at how the AWS availability zone plays a role in this -- since I also confirmed that Any other help on getting this to work would be appreciated! |
Did anyone ever find a solution to this? |
Hi Drew - I never did figure it out because it works for me and it's hard to pin down issues with other setups, unfortunately. If you could grant read access to me somehow I could probably take a look. Also once more, I would happily take a pairing session request so that we can work on this together! |
@drewbietron took me up on that pairing request 🎉 @drewbietron could you post that working snippet? |
Was able to get this working with the following query. Thanks for pairing on this @DSchau
Was also able to run a normal filter -> regex to only return certain files. Which looks like
One thing that held me up for a while is that my cache'd version of my graphQl schema was out of sync, and I believe it got into that state while I was trying to create a localFile node for an S3 asset that was not public. Basically if To debug possible S3 issues, make sure that |
I actually ran into the problem again, but was able to confirm that its not due to this plugin. Originally I was trying to run this plugin against a folder of images off of S3 (about ~150 images, all 10-20mb a piece) and it was not returning a local file for each image. Later on, when I was pairing with @DSchau, we tested it against just one image, and it worked fine (and still does!). The problem resurfaced when I began running the plugin against a folder of hundred + images and after further digging, the best I can gather is that it's due to The stock Gatsby API for creating a local file isn't waiting for an entire image file to download before returning that image back to this S3 plugin, therefore a |
Same problem. This shows names of the jpgs in the bucket:
However, localFile gives an error, and it's not present in the ___graphql explorer either. Our bucket in in Ireland, so may need to use https://s3-eu-west-1.amazonaws.com instead of https://s3.amazonaws.com How can we override the value that is hard-coded in this plugin? |
@Vacilando there's nothing hard coded in the plugin. It uses aws-sdk internally, and the |
If you need a separate URL -- you'd want to augment this piece: https://github.com/DSchau/gatsby-source-s3/blob/master/src/gatsby-node.js#L36 PRs welcome! |
I tried adding The solution will probably be in what @naheller said above on 9/9/2018:
This is I guess what you also mean by saying:
Guess the easiest would be to take the 'region' value (if submitted) from gatsby-config.js and construct the url in gatsby-node.js by using: |
I confirm things work (localFile is available) when using a bucket in the US East (N. Virginia) region. Thanks for the detective work @naheller and @jonathanbell. We need to make the URL configurable by region so that this works for all buckets. |
It is hardcoded, because the region needs to be part of the URL to avoid a Here's the endpoint that needs to be hit according to the AWS docs :
In our case we simply need to change this: gatsby-source-s3/src/gatsby-node.js Line 36 in cb32cc2
...into this: Url: `https://s3.${awsConfig.region ? `${awsConfig.region}.` : ''}amazonaws.com/${rest.Name}/${Key}`, This is exactly what #13 does, but it's been open for six months now... |
Hello Guys, How did you install the master code. since it is not published in npm yet. need help here. |
Hello! It’s Christmas so no not published yet. Maybe next week! |
Any update on this? Can't use with |
FYI, I ended up making my own version of Feel free to use it if it helps! Any contribution over there is more than welcome, including bug reports 🙂 I'll support it at least as long as the maintenance status for this plugin and |
@DSchau Hello and thank you for making this plugin!
I am having an issue with the image processing query which uses
gatsby-transformer-sharp
andgatsby-plugin-sharp
. These packages are installed, and the below query gives me backid
,Key
, andUrl
successfully.However the
file
part throws the following error:Unknown field localFile on type S3Image
.I'm still getting the hang of Gatsby, GraphQL, and S3, so any advice would be appreciated!
The text was updated successfully, but these errors were encountered: