コード例 #1
0
 public function get(RootFile $file)
 {
     try {
         $api = new Api();
         $result = $api->resource(sprintf('%s/%s', $file->getUploaderPath(), $file->getBasename('.' . $file->getExtension())));
         $file->setType($result['resource_type'] === 'image' ? 'image' : 'file');
         if ($result['resource_type'] === 'image') {
             $config = $this->uploaderConfig->get('thumbnails');
             $edition = new Edition("thumbnail", null, $file->getUploaderPath(), ['type' => 'image', 'height' => $config['height'], 'width' => $config['width'], 'crop' => $config['crop'], 'cloudinary_response' => $result], true);
             $edition->setUrl($this->resolveUrl($edition));
             $file->addEdition($edition);
         }
         return $file;
     } catch (Api\NotFound $e) {
         return ['error' => 'S0001'];
     }
 }
コード例 #2
0
 public function get(RootFile $file)
 {
     if (!file_exists($file->getPathname())) {
         return ['error' => 'S0001'];
     }
     if ($file->isImage()) {
         $thumbName = $file->generateEditionFilename("thumbnail");
         $thumbPath = sprintf('%s/%s', $file->getPath(), $thumbName);
         if (!file_exists($thumbPath)) {
             return ['error' => 'S0002'];
         }
         $edition = new Edition("thumbnail", $thumbPath, $file->getUploaderPath(), ['type' => 'image'], true);
         $edition->setUrl($this->resolveUrl($edition));
         $file->addEdition($edition);
     }
     return $file;
 }