Each file has the following properties and is accessed via /api/file
.
Complete details in FileProperties.
The unique id for this file. It will never change.
file
.
A date when the file was created.
A date when the file was last updated.
The name the file is known by.
A unique hash of the file. This is useful when you want to cache files locally, or avoid uploading a file you've already uploaded, because it is always unique to a file.
A Folder id. The unique id of a Folder that this file is contained in.
The file's size in bytes.
A string representing what kind of file this is.
A string describing the file. If it's a PDF it will be how many pages it contains. If it's an image it will give some resolution information.
Either Ready
or Processing
.
This indicates wehther the file has been processed for inclusion into The Game Crafter's file handling system.
Things like generating a preview image and creating a permanent storage location are done while processing.
A URI to an image that shows a small representation of the original image or the first page of a PDF document.
A URI to the permanent storage location of the file.
The Folder that this file is contained in.
A hash providing all the extra goodies we know about the file.
The methods used to fetch and manipulate files.
POST /api/file
Required. The unique session id provided by a Session method.
Optional. If not passed in, the filename will be used as the name.
Required. The file that you wish to upload.
Required. A Folder id.
Optional. Add a watermark to the thumbnail that's will be generated for an uploaded image file.
Returns:
{ "id" : "xxx", "name" : "A Card", ... }
PUT /api/file/xxx
See Create File for details.
DELETE /api/file/xxx
Required. The unique session id provided by a Session method.
Returns:
{ "success" : 1 }
GET /api/file/xxx
Optional. The unique session id provided by a Session method.
Optional. See "Relationships" in Intro and File Relationships above for details.
Optional. See "Relationships" in Intro and File Relationships above for details.
Returns:
{ "id" : "xxx", "name" : "My Game", ... }
GET /api/file/xxx/references
Return a list of all objects that use this File. Each object will have a full description of itself.
Required. The unique session id provided by a Session method.
Returns:
{ items : [ { "id" : "xxx", "name" : "My Avatar", ... }, { "id" : "xxx", "name" : "My Deck Card Back", ... }, ... ] }
POST /api/file/grid-image
You can create a bunch of File objects all at once by uploading a grid image to this API. The image will be split into smaller images, and you'll get an array of File objects back.
The images will be extracted across and then down. So if your grid has 9 images in 3 rows of 3 then it would be like:
1 2 3 4 5 6 7 8 9
If you only have 7 images, but the same grid layout then you would set quantity=7
the images extracted would be:
1 2 3 4 5 6 7
For that case the last to spaces in the grid will be ignored.
Required. The unique session id provided by a Session method.
Optional. If not passed in, the filename will be used as the name.
Required. The image that you wish to upload. The image cannot exceed 5000x5000 pixels.
Required. A Folder id.
The number of images that should be extracted from this image. Range between 1 and 100.
The width (in pixels) of the images to be extracted from this image.
The height (in pixels) of the images to be extracted from this image.
Returns:
{ "files" : [ { "file_uri" : "//s3.amazonaws.com/files.dev.thegamecrafter.com/78353d61fcfba20d113cbcb91adc1153780f91b8", "file_type" : "PNG", "sha1_digest" : "78353d61fcfba20d113cbcb91adc1153780f91b8", "date_updated" : "2021-01-30 23:28:36", "date_created" : "2021-01-30 23:28:36", "id" : "E024AC38-6352-11EB-92B1-B403F0027F2A", "status" : "Processing", "can_edit" : 1, "object_name" : "File", "file_size" : 8294.4, "image_size" : "825x1125", "s3file_id" : "D0F0FF3E-6350-11EB-A921-E51985A17141", "preview_uri" : "/preview_not_ready.gif", "can_view" : 1, "object_type" : "file", "folder_id" : "0AFF1012-373B-11E2-B3AB-C942AB40E458", "_warnings" : [], "details" : "825x1125 pixels", "name" : "1_gridimage.png" }, ... ] }