Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17244 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 17244 Rev 17245
Línea 505... Línea 505...
505
                $storage = Storage::getInstance($this->config, $this->adapter);
505
                $storage = Storage::getInstance($this->config, $this->adapter);
506
                $target_path = $storage->getPathMicrolearningCapsule();
506
                $target_path = $storage->getPathMicrolearningCapsule();
Línea 507... Línea 507...
507
 
507
 
Línea 508... Línea 508...
508
                $storage->setFiles($request->getFiles()->toArray());
508
                $storage->setFiles($request->getFiles()->toArray());
509
                
-
 
510
                if (!$storage->setCurrentFilename('image')) {
-
 
511
                    return new JsonModel([
-
 
512
                        'success'   => false,
-
 
513
                        'data'      => 'Error al setear el nombre del archivo'
-
 
514
                    ]);
-
 
515
                }
509
                
516
 
510
                if ($storage->setCurrentFilename('image')) {
517
                $target_size = $this->config['leaderslinked.image_sizes.microlearning_image_size'];
511
                    $target_size = $this->config['leaderslinked.image_sizes.microlearning_image_size'];
518
                list($target_width, $target_height) = explode('x', $target_size);
512
                    list($target_width, $target_height) = explode('x', $target_size);
519
 
513
    
520
                $source_filename = $storage->getTmpFilename();
514
                    $source_filename = $storage->getTmpFilename();
521
                $filename = 'capsule-' . uniqid() . '.jpg';
515
                    $filename = 'capsule-' . uniqid() . '.jpg';
522
                $target_filename = $storage->composePathToFilename(
516
                    $target_filename = $storage->composePathToFilename(
523
                    Storage::TYPE_MICROLEARNING_CAPSULE,
517
                        Storage::TYPE_MICROLEARNING_CAPSULE,
524
                    $capsule->uuid,
518
                        $capsule->uuid,
525
                    $filename
519
                        $filename
526
                );
520
                    );
527
 
521
    
528
                if (!$storage->uploadImageCrop($source_filename, $target_filename, $target_width, $target_height)) {
522
                    if (!$storage->uploadImageCrop($source_filename, $target_filename, $target_width, $target_height)) {
529
                    return new JsonModel([
523
                        return new JsonModel([
530
                        'success'   => false,
524
                            'success'   => false,
531
                        'data'      => 'Error al subir la imagen'
525
                            'data'      => 'ERROR_UPLOAD_IMAGE'
532
                    ]);
526
                        ]);
533
                }
527
                    }
534
 
528
    
-
 
529
                    if($capsule->image) {   
-
 
530
                        $storage->deleteFile($target_path, $capsule->uuid, $capsule->image);
-
 
531
                    }
535
                if($capsule->image) {   
532
    
Línea 536... Línea -...
536
                    $storage->deleteFile($target_path, $capsule->uuid, $capsule->image);
-
 
Línea 537... Línea 533...
537
                }
533
                    $capsule->image = $filename;
538
 
534
                }
539
                $capsule->image = $filename;
535
 
540
 
536