Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 546 Rev 549
Línea 124... Línea 124...
124
        $this->adapter = $adapter;
124
        $this->adapter = $adapter;
125
        $this->currentFile = [];
125
        $this->currentFile = [];
Línea 126... Línea 126...
126
 
126
 
127
        $this->storagePath = 'data' . DIRECTORY_SEPARATOR . 'storage';
127
        $this->storagePath = 'data' . DIRECTORY_SEPARATOR . 'storage';
128
        if (! file_exists($this->storagePath)) {
128
        if (! file_exists($this->storagePath)) {
129
            mkdir($this->tempPath, 0775);
129
            mkdir($this->storagePath, 0775, true);
Línea 130... Línea 130...
130
        }
130
        }
Línea 131... Línea 131...
131
 
131
 
132
        $this->tempPath = 'data' . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
132
        $this->tempPath = 'data' . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
133
 
133
 
134
        if (! file_exists($this->tempPath)) {
134
        if (! file_exists($this->tempPath)) {
Línea 135... Línea 135...
135
            mkdir($this->tempPath, 0775);
135
            mkdir($this->tempPath, 0775, true);
136
        }
136
        }
Línea 541... Línea 541...
541
     */
541
     */
542
    public function getGenericImage($path, $code, $filename)
542
    public function getGenericImage($path, $code, $filename)
543
    {
543
    {
544
        $remoto = $path . DIRECTORY_SEPARATOR . $code . DIRECTORY_SEPARATOR . $filename;
544
        $remoto = $path . DIRECTORY_SEPARATOR . $code . DIRECTORY_SEPARATOR . $filename;
Línea 545... Línea -...
545
 
-
 
546
 
-
 
547
 
-
 
548
 
-
 
549
 
545
 
550
        if (file_exists($remoto)) {
-
 
551
 
-
 
552
            if ($code == 'd8e6c5de-52a6-4c28-bdce-4ba2823ba841') {
-
 
553
 
-
 
554
                error_log('getGenericImage = ' . $remoto);
-
 
555
            }
-
 
556
 
546
        if (file_exists($remoto)) {
557
            return $this->getPresignedUrl($remoto);
547
            return $this->getPresignedUrl($remoto);
Línea 558... Línea 548...
558
        }
548
        }
559
 
549
 
Línea 870... Línea 860...
870
        }
860
        }
871
    }
861
    }
Línea 872... Línea 862...
872
 
862
 
873
    /**
863
    /**
874
     *
864
     *
875
     * @param string $path
865
     * @param string $type
876
     * @param string $code
866
     * @param string $code
877
     * @return boolean
867
     * @return boolean
878
     */
868
     */
879
    public function deleteDirectory($path, $code)
869
    public function deleteDirectory($type, $code)
-
 
870
    {
880
    {
871
        $path = $this->getPathByType($type);
881
        $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $code;
872
        $remoto = $path . DIRECTORY_SEPARATOR . $code;
882
        if (file_exists($remoto)) {
873
        if (file_exists($remoto)) {
883
            $this->deleteDirectoryRecursive($remoto);
874
            $this->deleteDirectoryRecursive($remoto);
884
            return true;
875
            return true;
885
        } else {
876
        } else {
Línea 897... Línea 888...
897
            $objects = scandir($dir);
888
            $objects = scandir($dir);
898
            foreach ($objects as $object) {
889
            foreach ($objects as $object) {
899
                if ($object != '.' && $object != '..') {
890
                if ($object != '.' && $object != '..') {
900
                    $s = $dir . DIRECTORY_SEPARATOR . $object;
891
                    $s = $dir . DIRECTORY_SEPARATOR . $object;
901
                    if (is_dir($s) && ! is_link($s)) {
892
                    if (is_dir($s) && ! is_link($s)) {
902
                        @rmdir($s);
893
                        $this->deleteDirectoryRecursive($s);
903
                    } else {
894
                    } else {
904
                        @unlink($s);
895
                        @unlink($s);
905
                    }
896
                    }
906
                }
897
                }
907
            }
898
            }
Línea 953... Línea 944...
953
     * @param string $url
944
     * @param string $url
954
     * @return string
945
     * @return string
955
     */
946
     */
956
    public function getPresignedUrl($url)
947
    public function getPresignedUrl($url)
957
    {
948
    {
958
 
-
 
959
 
-
 
960
        if (strpos($url, 'd8e6c5de-52a6-4c28-bdce-4ba2823ba841') !== false) {
-
 
961
            $show = true;
-
 
962
        } else {
-
 
963
            $show = false;
-
 
964
        }
-
 
965
 
-
 
966
 
-
 
967
        if ($show) {
-
 
968
            error_log('getPresignedUrl : ' . $url);
-
 
969
        }
-
 
970
 
-
 
971
        $code = hash('sha256', $url);
949
        $code = hash('sha256', $url);
Línea 972... Línea -...
972
 
-
 
973
        if ($show) {
-
 
974
            error_log('getPresignedUrl CODE : ' . $code);
-
 
975
        }
-
 
976
 
950
 
977
        $storageFileMapper = \LeadersLinked\Mapper\StorageFileMapper::getInstance($this->adapter);
951
        $storageFileMapper = \LeadersLinked\Mapper\StorageFileMapper::getInstance($this->adapter);
978
        $storageFile = $storageFileMapper->fetchOneByCode($code);
952
        $storageFile = $storageFileMapper->fetchOneByCode($code);
979
        if (! $storageFile) {
953
        if (! $storageFile) {
980
            $storageFile = new \LeadersLinked\Model\StorageFile();
954
            $storageFile = new \LeadersLinked\Model\StorageFile();
Línea 987... Línea 961...
987
            $storageFileMapper->insert($storageFile);
961
            $storageFileMapper->insert($storageFile);
988
        }
962
        }
Línea 989... Línea 963...
989
 
963
 
990
 
-
 
991
        $url = 'https://' . $_SERVER['SERVER_NAME'] . '/storage/' . $code;
-
 
992
        if ($show) {
-
 
993
            error_log('URL : ' .  $url);
964
 
994
        }
965
        $url = 'https://' . $_SERVER['SERVER_NAME'] . '/storage/' . $code;
995
 
966
        
Línea 996... Línea 967...
996
        return $url;
967
        return $url;
997
    }
968
    }