PHP SDK: StoredFile: the result of storing a file
Storage::put() and Storage::putFromUrl() return this object. It has no methods to call; read its properties.
| Property | Type | Purpose |
|---|---|---|
key |
string | Object key in storage; save it in a product record if needed |
size |
int | File size in bytes |
mime |
string or null | Content type, for example image/jpeg |
etag |
string or null | Object tag returned by the storage service |
dryRun |
bool | true means a trial operation without uploading the file |
$file = $ctx->storage('media')->put('reports/result.json', '{"ok":true}', 'application/json');
$ctx->log('File processed', [
'key' => $file->key,
'bytes' => $file->size,
'trial' => $file->dryRun,
]);
In a trial run, dryRun=true: a key is calculated, but no object is created. Its size and etag do not prove that a file exists. In a real run, obtain a temporary link with $ctx->storage('media')->url($file->key).
Do not assume that etag is always an MD5 checksum. Its value depends on the storage service and upload method.