A GraphQL service for managing files in VTEX applications. This service provides a simple interface for uploading, retrieving, and deleting files with support for image resizing.
This API is a GraphQL abstraction of the [email protected] app, providing a unified interface for file management. Usage
- File uploads with automatic UUID-based naming
- File retrieval with optional image resizing
- File URL generation for direct access
- File deletion
- Authentication requirements for sensitive operations
- Support for different storage buckets
To use this API, declare it in your manifest.json file:
"dependencies": {
"file-manager-graphql": "0.x"
}
Returns the immutable URL of a file.
Arguments | Type | Description |
---|---|---|
path | String | File path |
bucket | String | Bucket name |
Arguments | Type | Description |
---|---|---|
path | String | File path |
bucket | String | Bucket name |
width | Int | Image width |
height | Int | Image height |
aspect | Boolean | Maintain image aspect ratio |
Returns the API settings.
Saves a file and returns its immutable URL.
Arguments | Type | Description |
---|---|---|
file | File | File to be uploaded |
bucket | String | Bucket name |
Deletes a file from a bucket.
Arguments | Type | Description |
---|---|---|
path | String | File path |
bucket | String | Bucket name |
Field | Type | Description |
---|---|---|
fileUrl | String | File URL |
mimetype | String | File MIME type |
encoding | String | File encoding |
Field | Type | Description |
---|---|---|
maxFileSizeMB | Int | Maximum allowed file size (in MB) |
Getting a file URL
query {
getFileUrl(path: "path/to/file", bucket: "images") {
fileUrl
}
}
Getting a file
query {
getFile(path: "path/to/file", width: 100, height: 100, bucket: "images") {
file
}
}
Uploading a file
mutation {
uploadFile(file: ..., bucket: "images") {
fileUrl
}
}
The Boolean
scalar type represents true
or false
.
The Int
scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.
The String
scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
This service implements authentication directives to ensure that sensitive operations like file uploads and deletions are properly authorized.
This project is licensed under the terms specified in the package.json
file.