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

folder tree / images files #4

Open
marioamandio opened this issue Apr 22, 2019 · 5 comments
Open

folder tree / images files #4

marioamandio opened this issue Apr 22, 2019 · 5 comments

Comments

@marioamandio
Copy link

I'm new using Gatsby, I'd like to know if there's any way of query a folder tree and .png, .jpg files. And, if so, could you please provide some query examples?
Thank you in advance

@fabe
Copy link
Owner

fabe commented Apr 23, 2019

Hey @marioamandio! After this plugin downloads a folder, it behaves just like other files and folders in your filesystem. You can then use gatsby-source-filesystem to query them. For example:

// In your gatsby-config.js

module.exports = {
  plugins: [
    {
      resolve: `@fs/gatsby-plugin-drive`,
      options: {
        // ...
        destination: path.join(__dirname, 'src/data/'),
      }
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `gdrive`,
        path: `${__dirname}/src/data/`,
      },
    },
  ],
}
# In your queries

{
  allFile {
    edges {
      node {
        extension
        dir
        modifiedTime
      }
    }
  }
}

You can use GraphiQL (at http://localhost:8000/___graphql) to explore the queries and filtering options. Also take a look at the gatsby-source-filesystem documentation.

@marioamandio
Copy link
Author

marioamandio commented Apr 23, 2019

Hey again @fabe, thank you for your answer but didn't solve my problem, the configuration is in place and my google drive setup API is receiving the request and creates the folder that I can query but this folder is empty, is anything wrong with @fs/gatsby-plugin-drive configuration?

    {
      resolve: "@fs/gatsby-plugin-drive",
      options: {
        folderId: `DRIVE_FOLDER_ID`,
        keyFile: path.resolve(__dirname, "googleKey.json"),
        destination: path.join(__dirname, "src/data/"),
      },
    },


@fabe
Copy link
Owner

fabe commented May 29, 2019

Did you manage to fix this @marioamandio? The config looks fine.

@seth1993
Copy link

Having similar issue as @marioamandio where gatsby develop says downloading content but folder is empty

@bouiboui
Copy link

@marioamandio @seth1993

Make sure you create a service account first and then share your drive folder with the e-mail address shown here:
image

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

No branches or pull requests

4 participants