declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$request = new Components\DownloadableFileCreate(
name: '<value>',
mimeType: '<value>',
size: 612128,
upload: new Components\S3FileCreateMultipart(
parts: [],
),
);
$response = $sdk->files->create(
request: $request
);
if ($response->fileUpload !== null) {
// handle response
}
{
"id": "<string>",
"organization_id": "<string>",
"name": "<string>",
"path": "<string>",
"mime_type": "<string>",
"size": 123,
"storage_version": "<string>",
"checksum_etag": "<string>",
"checksum_sha256_base64": "<string>",
"checksum_sha256_hex": "<string>",
"last_modified_at": "2023-11-07T05:31:56Z",
"upload": {
"id": "<string>",
"path": "<string>",
"parts": [
{
"number": 123,
"chunk_start": 123,
"chunk_end": 123,
"checksum_sha256_base64": "<string>",
"url": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"headers": {}
}
]
},
"version": "<string>",
"is_uploaded": false,
"service": "downloadable",
"size_readable": "<string>"
}
Create a file.
Scopes: files:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$request = new Components\DownloadableFileCreate(
name: '<value>',
mimeType: '<value>',
size: 612128,
upload: new Components\S3FileCreateMultipart(
parts: [],
),
);
$response = $sdk->files->create(
request: $request
);
if ($response->fileUpload !== null) {
// handle response
}
{
"id": "<string>",
"organization_id": "<string>",
"name": "<string>",
"path": "<string>",
"mime_type": "<string>",
"size": 123,
"storage_version": "<string>",
"checksum_etag": "<string>",
"checksum_sha256_base64": "<string>",
"checksum_sha256_hex": "<string>",
"last_modified_at": "2023-11-07T05:31:56Z",
"upload": {
"id": "<string>",
"path": "<string>",
"parts": [
{
"number": 123,
"chunk_start": 123,
"chunk_end": 123,
"checksum_sha256_base64": "<string>",
"url": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"headers": {}
}
]
},
"version": "<string>",
"is_uploaded": false,
"service": "downloadable",
"size_readable": "<string>"
}
You can generate an Organization Access Token from your organization's settings.
Schema to create a file to be associated with the downloadables benefit.
File created.
The response is of type object
.
Was this page helpful?