Storage of files is an important feature of Hypi’s low code backend.
The process of file upload is easy and effortless. Just follow this guideline!
Here is a simple cURL request for file upload.
curl --location --request POST 'https://api.staging.hypi.dev/upload/' \
--header 'Accept: application/json' \
--header 'Authorization: Your_Key' \
--header 'hypi-domain: Your_Domain' \
--form '0=@"sa8sNsfXu/arcql.txt"'
#Result
{
"arcql.txt": {
"__typename": "File",
"hypi": {
"__typename": "Hypi",
"id": "01FSRCRNZQQ41JWD6E5TS0KMRA",
"impl": null,
"created": "2022-01-19T05:25:47Z",
"updated": "2022-01-19T05:25:47Z",
"trashed": null,
"createdBy": "01FQDY5XDRQPERKPCWAWYDFV7W",
"instanceId": "01FQDYDP8681299EXZBWJXRX2Y",
"tags": null
},
"name": "arcql.txt",
"directory": "/",
"path": "/arcql.txt",
"isDirectory": false,
"status": "UPLOADED",
"url": {
"__typename": "URL",
"hypi": {
"__typename": "Hypi",
"id": "01FSRCRNZS7051YAG0SHH2P5K1",
"impl": null,
"created": "2022-01-19T05:25:47Z",
"updated": "2022-01-19T05:25:47Z",
"trashed": null,
"createdBy": "01FQDY5XDRQPERKPCWAWYDFV7W",
"instanceId": "01FQDYDP8681299EXZBWJXRX2Y",
"tags": null
},
"path": "/file/01FQDYDP8681299EXZBWJXRX2Y-01FSRCRNZQQ41JWD6E5TS0KMRA.txt",
"queryParams": null,
"port": null,
"host": null
},
"type": "text/plain",
"size": 15011,
"extension": "txt",
"isStared": null,
"isSharable": null,
"content": null,
"children": null
}
}
You may assign hypi.id
of the uploaded file to any field with File
type. Let’s say you have Student data type and you want to store Resume of the student. So, you may have something like this.
type Student {
name: String
resume: File
}
Store the file in the resume
field of the Student data type using hypi.id
of the uploaded file.
Please note Hypi accepts multiple file types. All the image files get saved as Image
data type.
Above cURL
request has been auto-generated on POSTMAN. You may check the request File Upload
on below POSTMAN collection link.
- Replace below headers in the request with your own
Authorization
andhypi-domain
values.
--header 'Authorization: Your_Key' \
--header 'hypi-domain: Your_Domain' \
- Replace the URL path as well.
https://api.staging.hypi.dev/upload/
- On POSTMAN, you may select the file to uploaded.
Body=>form-data=> Select File type=> Add key 0=> Select file as Value
-
@
is the root directory of the file to be uploaded. For uploading file without POSTMAN, you may provide your own file path in front of it. - Check File Upload code snippets for different programming languages. Click
</>
.
You may check Image Upload post here
Profile Image Upload using Hypi