HomeGuidesAPI ReferenceChangelogDiscussions
HomeLog In
Guides

Create Media

URL

POST https://open.shopline.io/v1/media

Request Body

FieldTypeDescription
databinaryupload file binary
容量限制為 8MB 或 8388608 bytes
支援格式為 png gif jpeg jpg
圖片長寬限制為 16000 x 16000 px
The maximum file size is 8MB or 8388608 bytes
Support png gif jpeg jpg data
The image size is limited to 16,000 x 16,000 pixels.

Sample Request

Header

FieldType
AuthorizationStringBearer authentication with access token given
curl --location --request POST '<<api_domain>>/v1/media' \
--header 'Authorization: Bearer ${access_token}' \
--form 'data=@/path/wallpaper.png'

We accept multipart/form-data

An example to upload a file with okhttp
https://gist.github.com/balvinder294/e869944161cb0af250b1296f64e3129a

An example to upload a file with php curl
https://gist.github.com/maxivak/18fcac476a2f4ea02e5f80b303811d5f
guzzle
https://github.com/guzzle/guzzle/issues/2296

An example to upload a file with nodejs axios
https://maximorlov.com/send-a-file-with-axios-in-nodejs/

Sample Response

{
    "result": true,
    "message": "",
    "data": {
        "images": {
            "original": {
                "width": 120,
                "height": 120,
                "url": "https://img.shoplineapp.com/media/image_clips/6217735bee0709002ff6fdd5/original.png?1645704027"
            }
        },
        "_id": "6217735bee0709002ff6fdd5",
        "alt_translations": {}
    },
    "status": 200,
    "images": {
        "original": {
            "width": 120,
            "height": 120,
            "url": "https://img.shoplineapp.com/media/image_clips/6217735bee0709002ff6fdd5/original.png?1645704027"
        }
    },
    "_id": "6217735bee0709002ff6fdd5",
    "alt_translations": {}
}

Failures

When file size exceeds limit or the file is not a valid media.

{
    "result": false,
    "message": "unprocessable_entity",
    "status": 422
}