Type to search...

Upload: stream

Uploads binary content.

Request

The request should be sent to POST /multipart/related API endpoint, for more details, click here.

HTTP request

POST /upload/v1/c/<cloudId> HTTP/1.1

Parameters

Parameter name Value Description
Path parameters
cloudId string Cloud ID where you upload the image.
Optional query parameters
projection string Projection settings; comma separated string see

Request Body

Property name Value Description Note
Required Properties
file binary Binary content of the file
publicId string Public Image ID to use with the image.
Optional Properties
transformation string Transformations on the image, affect the image before storing to the cloud
format string Image format to be stored
plugins string Plugins; comma separated string
tags string[] Tags for the image
allowOverride bool Allowing override of the image if public ID already exists

Response

If successful, this method returns a image resource in the response body.

Response HTTP status code

HTTP status code Description
200 Successfully uploaded
400 Bad request, for example bad transformation string
409 The public ID already exists
422 Unprocessable image, for example too small size of image

For more information about HTTP codes, click here.

Rate limit

Detailed information for image rate limitation is available on Shardimage developers.

SDK

use shardimage\shardimagephp\auth\Client;
use shardimage\shardimagephp\factories\Transformation;
 
$client = new Client([
    'apiKey' => '<apiKey>',
    'apiSecret' => '<apiSecret>',
    'imageSecret' => '<imageSecret>',
]);
 
$params = [
    'file' => '<filePatch>',
    'cloudId' => '<cloudId>',
    'publicId' => '<publicId>',
    //'publicId' => UploadHelper::generateRandomPublicId(),  // or can be generated
];
$transformations = new Transformation();
$transformations->toJpeg();
$optParams = [      // Optional parameters
    'transformation' => $transformations
];
 
$response = $client->getUploadService()->upload($params, $optParams);
Table of contents