Wix Media Platform is a collection of services for storing, serving, uploading, and managing media files and any files in general
This artifact is a PHP library, compatible with PHP 5.6+ and PHP 7.
The respective JavaScript (for the Browser and Node.js) package can be found here.
The respective Java package can be found here.
PHP 5.6 and later.
Firebase PHP JWT (JSON Web Tokens)
To install the bindings via Composer, add the following to composer.json
:
{
"repositories": [
{
"type": "git",
"url": "https://github.com/wix/media-platform-php-sdk.git"
}
],
"require": {
"wix/media-platform-php-sdk": "*"
}
}
Then run composer install
Download the files and include autoload.php
:
require_once('/path/to/sdk/media-platform-php-sdk/autoload.php');
First, if you haven't done so yet, register at Wix Media Platform, create your organization, project and application.
$mediaPlatform = new \Wix\Mediaplatform\MediaPlatform(
"<project host as appears in the application page>",
"<application id as appears in the application page>",
"<shared secret as appears in the application page>"
);
$file = fopen("...path to file...", "r");
$files = $mediaPlatform->fileManager()->uploadFile("/destination_path/file_name.ext", "mime_type", "file_name.ext", file, "private||public");
Generates a signed URL and token, required for uploading from the browser
$getUploadUrlResponse = $mediaPlatform->fileManager()->getUploadUrl();
The Jobs API forms the basis for all long running asynchronous operations in the platform.
A job is created by a service that performs a long running operation, such as video transcode or file import.
- On job creation it is queued for execution and assumes the 'pending' status.
- When the job execution commences, the job status changes to 'working'
- On job completion the job assumes one of the following statuses: 'success' or 'error' and the 'result' property is populated
$job = $mediaPlatform->jobManager()->getJob("job id");
$importFileRequest = new \Wix\Mediaplatform\Model\Request\ImportFileRequest();
$destination = new \Wix\Mediaplatform\Model\Job\Destination();
$destination->setPath("/to/file.ext")
->setAcl("private||public")
$importFileRequest->setSourceUrl("from URL")
->setDestination($destination);
$job = $mediaPlatform->fileManager()->importFile($importFileRequest);
File access can be restricted by setting the acl to 'private', in order to access them a secure URL must be generated
$signedUrl = $mediaPlatform->fileDownloader()->getDownloadUrl("path/to/file.ext");
The SDK provides a programmatic facility to generate image URLs
$image = new \Wix\Mediaplatform\Image\Image($fileDescriptor);
$image->setHost("images service host");
$image->crop($width, $height, $x, $y, $scale);
$url = $image->toUrl();
Wix Media Platform exposes a comprehensive set of APIs tailored for the management of files.
$response = $mediaPlatform->fileManager()->listFiles("directory path");
$fileMetadata = $mediaPlatform->fileManager()->getFileMetadataById("file id");
$mediaPlatform->fileManager()->deleteFileById("file id");
Instead of uploading numerous files one by one, it is possible to upload a single zip file and order the Media Platform to extract its content to a destination directory.
$extractArchiveRequest = new \Wix\Mediaplatform\Model\Request\ExtractArchiveRequest();
$source = new \Wix\Mediaplatform\Model\Job\Source();
$source->setFileId("file id");
$destination = new \Wix\Mediaplatform\Model\Job\Destination();
$destination->setAcl("public")
->setDirectory("/demo/extracted");
$extractArchiveRequest
->setSource($source)
->setDestination($destination);
$job = $mediaPlatform->archiveManager()->extractArchive($extractArchiveRequest);
Please use the issue tracker to report issues related to this library, or to the Wix Media Platform API in general.
We use a custom license, see LICENSE.md.
Wix.com is a leading cloud-based web development platform with more than 100 million registered users worldwide. Our powerful technology makes it simple for everyone to create a beautiful website and grow their business online.
Google Cloud Platform enables developers to build, test and deploy applications on Google’s reliable infrastructure. It offers computing, storage and application services for web, mobile and backend solutions.