diff --git a/src/CloudinaryAdapter.php b/src/CloudinaryAdapter.php index 5020ede..bf05578 100644 --- a/src/CloudinaryAdapter.php +++ b/src/CloudinaryAdapter.php @@ -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; } /** @@ -359,7 +372,7 @@ protected function prepareSize($resource) $size = $resource['bytes']; return compact('size'); } - + /** * Get the URL of an image with optional transformation parameters *