How to use the gatsby-source-filesystem.createRemoteFileNode function in gatsby-source-filesystem

To help you get started, we’ve selected a few gatsby-source-filesystem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jessestuart / gatsby-source-s3-image / src / __tests__ / source-nodes.spec.ts View on Github external
beforeEach(() => {
    sourceNodeArgs.store = configureMockStore()
    ListObjectsMock.mockReset()
    // Mock out Gatby's source-filesystem API.
    sourceFilesystem.createRemoteFileNode = jest
      .fn()
      .mockReturnValue(FileSystemNodeMock.build())
  })
github njosefbeck / gatsby-source-stripe / src / LocalFile.js View on Github external
async downloadStripeHostedFile(url, type, parentNodeId) {
    if (!url) return null;

    try {
      const fileNode = await createRemoteFileNode({
        url,
        ext: `.${type}`,
        parentNodeId,
        ...this.createRemoteArgs
      });

      return this.validateFileNodes(fileNode);
    } catch (e) {
      console.log(
        `\x1b[1;31m\u2715\x1b[0m We were unable to download files that Stripe was hosting\nURL: ${url}\n` +
          `Error: ${e.message}\n`
      );
      return null;
    }
  }
github AndreasFaust / gatsby-source-custom-api / utils / loadImages.js View on Github external
async function createImageNodes ({
  entity,
  createNode,
  createNodeId,
  store,
  cache,
  imageName,
  imageCacheKey
}) {
  let fileNode
  try {
    fileNode = await createRemoteFileNode({
      url: entity.data.url,
      store,
      cache,
      createNode,
      createNodeId
    })
  } catch (e) {
    console.log(e)
  }
  if (fileNode) {
    await cache.set(imageCacheKey, {
      fileNodeID: fileNode.id,
      modified: entity.data.modified
    })
    console.log('Image downloaded: ' + imageName)
    return {
github njosefbeck / gatsby-source-stripe / src / helpers / createFileNode.js View on Github external
async function createFileNode({
  store,
  cache,
  createNode,
  createNodeId,
  url,
  node
}) {
  try {
    const fileNode = await createRemoteFileNode({
      url,
      parentNodeId: node.id,
      store,
      cache,
      createNode,
      createNodeId
    });

    if (fileNode) {
      await saveToCache(cache, cacheKey(url), {
        fileNodeId: fileNode.id,
        updated: node.updated
      });
      return fileNode.id;
    }
  } catch (e) {
github njosefbeck / gatsby-source-stripe / src / LocalFile.js View on Github external
.map(url => {
          const createRemoteArgs = authFlag
            ? { url, parentNodeId, ...this.createRemoteArgs }
            : { url, parentNodeId, ...createRemoteArgsWithoutAuth };

          return createRemoteFileNode(createRemoteArgs);
        });
      const fileNodes = await Promise.all(fileNodePromises);
github fikaproductions / fika-gatsby-source-cockpit / src / FileNodeFactory.js View on Github external
async createAssetNode(path) {
    const assetNode = await createRemoteFileNode({
      url: path,
      store: this.store,
      cache: this.cache,
      createNode: this.createNode,
      createNodeId: () => generateNodeId('Asset', `${hash(path)}`),
    })

    return this.checkIfDownloadIsSuccessful(path, assetNode)
  }
github fikaproductions / fika-gatsby-source-cockpit / src / FileNodeFactory.js View on Github external
async createImageNode(path) {
    const imageNode = await createRemoteFileNode({
      url: path,
      store: this.store,
      cache: this.cache,
      createNode: this.createNode,
      createNodeId: () => generateNodeId('Image', `${hash(path)}`),
    })

    return this.checkIfDownloadIsSuccessful(path, imageNode)
  }

gatsby-source-filesystem

Gatsby source plugin for building websites from local data. Markdown, JSON, images, YAML, CSV, and dozens of other data types supported.

MIT
Latest version published 6 months ago

Package Health Score

85 / 100
Full package analysis