Skip to content

Commit

Permalink
Merge pull request #5 from mukutu-de/master
Browse files Browse the repository at this point in the history
feat(stream): hand over public_id and resource_type to uploader
  • Loading branch information
carlosocarvalho authored Aug 22, 2019
2 parents a2046e8 + 3f2c06d commit 69145a3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/CloudinaryAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,21 @@ public function write($path, $contents, Config $options)
*/
public function writeStream($path, $resource, Config $options)
{
$public_id = $options->has('public_id') ?
$options->get('public_id') : $path;

$resource_type = $options->has('resource_type') ?
$options->get('resource_type') : 'auto';

$resourceMetadata = stream_get_meta_data($resource);
$uploadedMetadata = Uploader::upload($resourceMetadata['uri'], ['public_id' => $path]);
$uploadedMetadata = Uploader::upload(
$resourceMetadata['uri'],
[
'public_id' => $public_id,
'resource_type' => $resource_type,
]
);

return $uploadedMetadata;
}
/**
Expand Down Expand Up @@ -359,7 +372,7 @@ protected function prepareSize($resource)
$size = $resource['bytes'];
return compact('size');
}

/**
* Get the URL of an image with optional transformation parameters
*
Expand Down

0 comments on commit 69145a3

Please sign in to comment.