Create media
Description
Create a new media
Important: this method uses the “multipart/form-data” format, because of file upload efficiency
Url
1 |
POST /api/v0/media/ |
Parameters
optional
- file: file with the new media object
Example
Create a media object, using local file new_logo.jpg
Request
1 2 3 |
curl -X POST \ 'https://my.craftar.net/api/v0/media/?api_key=123456789abcdefghijk123456789abcdefghijk' \ -F "file=@new_logo.jpg" |
Response
HTTP Status code: 201 Created
1 2 3 4 5 6 7 |
{ "uuid": "4ca4a87ce2a740e2a8b6c80f441ee2d4", "resource_uri": "/api/v0/media/4ca4a87ce2a740e2a8b6c80f441ee2d4/", "name": "new_logo.jpg", "mimetype": "image/jpeg", "file": "https://example.com/media/4ca4a87ce2a740e2a8b6c80f441ee2d4/new_logo.jpg" } |
Errors
HTTP Status code: 400 Bad Request
POST data is not in multipart/form-data
1 2 3 4 5 6 |
{ "error": { "message": "Expected multipart/form-data content but got text/plain.", "code": "WRONG_CONTENT_TYPE" } } |
Invalid media
1 2 3 4 5 6 |
{ "error": { "message": "Couldn't determine the type for the uploaded media.", "code": "MEDIA_INVALID" } } |