Reputation: 5237
I'm trying to build a website with Gatsby using with a Contentful CMS source. So far, I've built pages, used images and everything has been quite clear. But now, I'm trying to use an asset linked into one of my content types but I can't find an URL to download it or another way to use it. The asset I'm talking about is a GPX files, not an image. While Gatsby documentation about images is exhaustive, there's little said about other type of files.
My goal is to get the GPX file in one of my React component, parse it and display it on a map. But first I need to download it. So here's my question, how do I do that with Gatsby?
I checked the GraphiQL, but not a single property returns an actually working URL. 😕
The url
field selected in the screenshot returns a broken url (not-https).
downloadLocal
to true
I set downloadLocal
to true, ran gatsby build
and then ran gatsby develop
. But when I run the query in graphiQL I still receive the same url. 😕
{
"gpxPath": {
"file": {
"url": "//assets.ctfassets.net/xxxxxxxxxxxx/59R3KRl13Ppvwh2EGDspjh/41274fe0385d640faa4a092ef3a94804/Lac_de_la_Sassi_re.gpx"
}
}
}
Upvotes: 1
Views: 668
Reputation: 29320
Have you tried enabling the option downloadLocal
configuration option?
This will download the asset locally and should provide a valid URL for static distribution.
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: `your_space_id`,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
downloadLocal: true,
},
},
As long as your site is deployed to an HTTPS URL it should be a valid route.
Upvotes: 1