Create Media
uploadMedia
For creating a new media you need to use uploadMedia and provide a valid file path, file type, and file name.
Allowed file types are: jpeg, gif, png, jpg, pdf.
Parameters
- path: (string) - The file path to upload.
- type: (string) - The MIME type of the file.
- fileName: (string) - The name of the file.
Returns
Promise<ResponseType<MediaType>>: A promise that resolves with aMediaTypeobject containing the uploaded media data.
Example
import { uploadMedia } from 'react-native-altibbi';
uploadMedia("file://pathToFile.pdf", 'application/pdf', 'fileName.pdf').then((res) => {
console.log(`Media ID: ${res?.data?.id}`);
});
Responses
Status 200
Success
{
"id": "1234123",
"type": "image",
"name": "Test file",
"path": "doc/2024/02/05/60037901f47939872a6e1bdb9a65f604.png",
"extension": "png",
"size": 362875,
"url": "https://altibbi.com/Medias/12123/2331.png"
}
Status 401
UnauthorizedHttpException represents an Unauthorized HTTP exception with status code 401.
{
"name": "Unauthorized",
"message": "Your request was made with invalid credentials",
"code": "0",
"status": "401",
"type": "yii\\web\\UnauthorizedHttpException"
}
Status 422
Data Validation Failed.
[
{
"field": "string",
"message": "string"
}
]