Coder Social home page Coder Social logo

gql-multimedia-upload-api's Introduction

GraphQL Asset Upload API

A GraphQL API that allows users to upload various types of files (images, documents, etc.) and store the associated metadata.

Technologies Used:

Running the project without docker

  • Create a database or use an online database
  • Fill all the environment variables with intellij or directly
  • Click the run button on intellij

Execute mutations on http://localhost:8080/graphiql?path=/graphql. If you have changed the port, replace 8080 with your new port.

See sample mutation below:

mutation {
    getPresignedUrl(asset: [
        {
            name: "exampleAsset1",
            extension: "jpg",
            metadata: [
                { key: "author", value: "John Doe" },
                { key: "description", value: "An example image" }
            ]
        },
        {
            name: "exampleAsset2",
            extension: "png",
            metadata: [
                { key: "author", value: "Jane Smith" },
                { key: "description", value: "Another example image" }
            ]
        }
    ]) {
        id
        presignedUrl
    }
}

And below is a sample response

{
  "data": {
    "getPresignedUrl": [
      {
        "id": "94cedad6-47a2-495e-91ee-8f4ed3446d53",
        "presignedUrl": "https://gqlassetuploadapi.s3.eu-north-1.amazonaws.com/exampleAsset1?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20231217T002243Z&X-Amz-SignedHeaders=host&X-Amz-Expires=299&X-Amz-Credential=ACCESS_KEy%2F20231217%2Feu-north-1%2Fs3%2Faws4_request&X-Amz-Signature=3a15ef4860d7a2af043a4eb232396b6a30738b83fec1a31a0a28e70ecee150fa"
      },
      {
        "id": "9c40499c-eaef-4f57-bb33-bc518c13823a",
        "presignedUrl": "https://gqlassetuploadapi.s3.eu-north-1.amazonaws.com/exampleAsset2?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20231217T002243Z&X-Amz-SignedHeaders=host&X-Amz-Expires=299&X-Amz-Credential=ACCESS_KEY%2F20231217%2Feu-north-1%2Fs3%2Faws4_request&X-Amz-Signature=cfee692521ebd093d7fd2ce2372d6c93a348e7b2ed4430f801d1c22013346d0b"
      }
    ]
  }
}

Future Considerations

  • Using Amazon Simple Queue to publish new assets and run presignedUrl generation in the background
  • Unit and Integration Testing
  • User Docker
  • Error Handling
  • Duplicate management
  • API versioning

Reasons for choosing presignedUrls

  • It scales well
  • It is the recommended approach

Resources

https://spring.io/guides/gs/graphql-server/

https://www.apollographql.com/blog/file-upload-best-practices

gql-multimedia-upload-api's People

Contributors

danielbontii avatar

Watchers

 avatar

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.