Git Product home page Git Product logo

Comments (3)

koistya avatar koistya commented on May 27, 2024 2

@phpb-com yes, there is api/src/mutations/getUploadURL.ts and api/src/mutations/saveUpload.ts on the API side. All you have to do on the client is to request "upload URL", send the file(s) via HTTP PUT to that URL, then send "uploaded file URL" to the saveUpload() API mutation (which copies the file over from a temporary upload bucket location to a permanent place based on the linked content type (user photo, blog post pictures, etc.). As was described here.

from graphql-starter-kit.

koistya avatar koistya commented on May 27, 2024

Yep, it will be added soon. It would look like an API endpoint that generates upload URL (to Google Storage Bucket or Amazon S3). The client app would request that URL and upload file(s) directly to cloud storage using HTTP PUT request.

mutation {
  getUploadURL(filename: "hello-world.jpg", ...)
}
await fetch(uploadURL, { method: "PUT", body: file });

Each uploaded file needs to have a unique URL (e.g. by prefixing it with file ID) so it can be permanently cached at the CDN level. And then can be requested directly from google storage by client app(s). For example:

https://s.example.com/nv4fzx/hello-world.jpg

Where s.example.com is a CDN endpoint (CNAME) pointing to gs://s.example.com GCS bucket, and nv4fzx is a unique file ID.

Also, it can be complemented with yet another cloud function that can be used to transform uploaded images via URL parameters, similarly to Cloudinary:

https://i.example.com/w_80,h_60,c_fill/nv4fzx/hello-world.jpg

Files

References

https://googleapis.dev/nodejs/storage/latest/File.html#generateSignedPostPolicyV4
https://cloud.google.com/functions/docs/tutorials/imagemagick
https://zelark.github.io/nano-id-cc/

P.S.: Join our Discord channel to discuss this feature https://discord.com/invite/bSsv7XM

from graphql-starter-kit.

phpb-com avatar phpb-com commented on May 27, 2024

Any update on this? Thanks.

from graphql-starter-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.