File uploads using the File API are not governed by the permissions on the File type. As such, everyone can upload files to your project. Please reach out in the Forum or Slack if you have any questions about this.

Uploading a file will result in a response containing the new file id and the url. Let's upload our first file now. Pick a funny picture or similar and upload it! You can then go to the URL in the response to verify that the image file was correctly uploaded.

Remember to replace the file endpoint. You can copy your file endpoint from inside your project.

Regardless of your HTTP library, make sure to set the header Content-Type to multipart/form-data and use the file key data.

after replacing __PROJECT_ID__ with your project id and example.png with the name of your file. The uploaded file will receive the new file name myname.png. You can copy your file endpoint from inside your project.

Files are secured using a unique and unguessable secret. You can protect this secret by using the read permissions on the File type as with any other type. For example, you can restrict access to a file's secret to authenticated users.

File downloads however are currently not governed by permissions on the File type. As such, everyone with a file's secret and the project id can download a file. Please reach out in the Forum or Slack if you have any questions about this.

The Image API provides a very thin layer on top of the File API for image transformations.

Once an image has been calculated, it is persisted at the respective URL. Calling it again will not initiate another calculation. Only images up to 25MB can be transformed, and final results up to 6MB can be downloaded.

Cropping

https://images.graph.cool/v1/__PROJECT_ID__/__FILE_SECRET__/0x0:400x400: Crops the image taking the first 400x400 square

Cropping starts from left-top corner

Name

https://images.graph.cool/v1/__PROJECT_ID__/__FILE_SECRET__/__IMAGE_NAME__.__EXTENSION__: Name of image in URL to improve SEO
https://images.graph.cool/v1/__PROJECT_ID__/__FILE_SECRET__/Graphcool.jpg: Get image with name Graphcool.jpg

Supported extensions:

png

jpg

jpeg

svg

gif

bmp

webp

Resizing, cropping and naming

https://images.graph.cool/v1/__PROJECT_ID__/__FILE_SECRET__/0x0:400x400/250x250/Graphcool.jpg: Crops the image taking the first 400x400 square and fit into 250px x 250px rectangle and rename it to Graphcool.jpg

Images are cropped before being resized.

Contributions

Contributions and improvements to the Image API are welcome! For more information, see serverless-image-proxy.