Uploads file to amazon s3
@param  string $sourcePath path name to file on local storage
@param  string $targetPath      path in which would be image saved in S3
@param  bool $allowRewriteFile
@return
421130
public function uploadFile($sourcePath, $targetPath, $publicAccess = true, $allowRewriteFile = false)
	{
		// check if the file does not already exists, if exist, don't upload
		if ($allowRewriteFile !== true && $this->isFile($targetPath)) {
			return false;
		}
		return $this->s3Client->putObject(array(
			'Bucket'     => $this->getBucket(),
			'Key'        => $targetPath,
			'SourceFile' => $sourcePath,
			'ACL'        => $publicAccess ? self::PUBLIC_READ : self::PRIVATE_ACCESS
		));
	}
986596
public function upload($sourceFile, $destinationFile)
    {
        Service::$log->msg('Upload to S3 started: ' . $sourceFile);
        $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/' . $destinationFile;
        $this->s3Instance->multipartUpload($this->s3Config->Bucket, $destinationFile, $sourceFile, 3);
        Service::$log->msg('Upload ended');

        return $destinationFile;
    }
782776
public function uploadFileWithFolderAndName(UploadedFile $file, $folderPath, $fileName)
    {

        $folderPath = !empty($folderPath) ?   $folderPath  . '/' : '';
        $path =   $this->env . '/' . $folderPath . $fileName . '.'. $file->guessClientExtension();
        /** @var Result $result */
        $result = $this->client->putObject([
            'ACL' => 'public-read',
            'Bucket' => $this->bucketName,
            'SourceFile' => $file->getRealPath(),
            'Key' => $path
        ]);
        
        return new FileUploadedModel($path, $result->get('ObjectURL'), FileUploadedModel::VENDOR_S3);
    }
812553
protected function move($sourcePath, $targetPath)
    {
        if ($this->filesystem->has($targetPath)) {
            return false;
        }

        $stream = fopen($sourcePath, 'r+');
        if ($stream === null) {
            return false;
        }

        $success = $this->filesystem->writeStream($targetPath, $stream);

        if (fclose($stream) === false) {
            return false;
        }

        unlink($sourcePath);

        return $success;
    }
581998
protected function moveFilesIntoTargetFolder($sourcePath, $targetPath)
    {
        $filesystem = new \Symfony\Component\Filesystem\Filesystem();
        $filesystem->mirror($sourcePath, $targetPath);
        $finder     = new \Symfony\Component\Finder\Finder();
        $iterator   = $finder->files()->ignoreUnreadableDirs(true)->followLinks()->in($sourcePath);
        $sFiles     = [];
        foreach ($iterator as $file) {
            $relativePathFile = str_replace($sourcePath, '', $file->getRealPath());
            if (!file_exists($targetPath . $relativePathFile)) {
                $sFiles[$relativePathFile] = $targetPath . $relativePathFile;
            }
        }
        return $this->setArrayToJson($sFiles);
    }
1179636
protected function createCommand($resourcePath, $targetPath, Options $options)
    {
        $commandLineOptions = implode(' ', $this->commandLineOptions);

        $optionArray = $options->toArray();
        $encodedOptions = escapeshellarg(json_encode($optionArray));

        $commandSegments = [];

        $commandSegments[] = $this->binaryPath;
        $commandSegments[] = $commandLineOptions;
        $commandSegments[] = __DIR__ . '/../js/phantom-pdf.js';
        $commandSegments[] = $resourcePath;
        $commandSegments[] = $targetPath;
        $commandSegments[] = $encodedOptions;

        return implode(' ', $commandSegments);
    }
1323828
public static function dir($sourcePath, $outZipPath)
    {
        $sourcePath = rtrim($sourcePath, "/");
        $zip = new ZipArchive();
        $zip->open($outZipPath, ZipArchive::CREATE);
        self::folderToZip($sourcePath, $zip, strlen($sourcePath . "/"));
        $zip->close();
    }
7634
public function save($imageTargetFilePath, $quality = 100)
    {
        $resampleImageResource =& $this->getResampleImageResource();

        $extension = pathinfo($imageTargetFilePath, PATHINFO_EXTENSION);

        switch ($extension) {
            case 'jpg':
            case 'jpeg':
                return (bool)@imagejpeg($resampleImageResource, $imageTargetFilePath, $quality);
                break;

            case 'gif':
                return (bool)@imagegif($resampleImageResource, $imageTargetFilePath);
                break;

            case 'png':
                imagealphablending($resampleImageResource, false);
                imagesavealpha($resampleImageResource, true);

                return (bool)@imagepng($resampleImageResource, $imageTargetFilePath);
                break;

            case 'webp':
                return (bool)@imagewebp($resampleImageResource, $imageTargetFilePath);
                break;
        }

        return false;
    }
1023458
function MoveTo($targetFolder, $targetFilename = '')
    {
        if (!$targetFilename)
            $targetFilename = $this->Filename();
        
        $destination = Path::Combine($targetFolder, $targetFilename);
        $result = @move_uploaded_file($this->TempPath(), $destination);
        if (!$result)
            throw new \Exception('Uploaded file could not be moved to target');
    }
39804
static function touchFile($filePath, $overwrite = true)
    {
        if (file_exists($filePath) && $overwrite == false) {
            return false;
        } elseif (file_exists($filePath) && $overwrite == true) {
            if (!unlink($filePath)) {
                return false;
            }
        }
        $aimDir = dirname($filePath);
        if (self::createDirectory($aimDir)) {
            try {
                return touch($filePath);
            } catch (\Throwable $throwable) {
                return false;
            }
        } else {
            return false;
        }
    }
1241964
public static function convertJsonToIni( $sourceFile, $targetFile )
	{
		$data	= self::loadJson( $sourceFile );
		return self::saveIni( $targetFile, $data );
	}
46512
public static boolean coreExpandArchive(String sourcePath, String targetPath) throws IOException {
        ZipArchiveInputStream in = null;
        OutputStream out = null;

        try {

            // make sure we're working with absolute canonical paths
            File source = new File(sourcePath).getCanonicalFile();
            File target = new File(targetPath).getCanonicalFile();

            // open the archive
            in = new ZipArchiveInputStream(getInputStream(source));

            // expand all entries of the archive
            for (ZipArchiveEntry entry = in.getNextZipEntry(); entry != null; entry = in.getNextZipEntry()) {

                // get the pathname of the entry (this will be a relative path)
                String outFilename = entry.getName();

                // construct the absolute path of where this entry will be expanded
                String targetPlusOutFile = target.getPath() + File.separator + outFilename;

                File targetFile = new File(targetPlusOutFile);
                char ending = outFilename.charAt(outFilename.length() - 1);

                if (ending == '/' || ending == '\\') {
                    fileMkDirs(targetFile);
                    if (helper != null) {
                        helper.setPermissions(targetFile, entry.getUnixMode());
                    }
                    continue;
                } else {
                    fileMkDirs(targetFile.getParentFile());
                }

                // expand the entry
                out = getOutputStream(targetFile);
                byte[] buf = new byte[1024];
                int len;
                while ((len = in.read(buf)) > 0) {
                    out.write(buf, 0, len);
                }

                // Close the streams
                out.close();

                if (helper != null) {
                    helper.setPermissions(targetFile, entry.getUnixMode());
                }

                out = null;
            }
            in.close();
            in = null;

            return true;

        } catch (IOException e) {
            throw e;
        } finally {
            // try to close any open files
            tryToClose(out);
            tryToClose(in);
        }
    }
1346508
public function upload($source, $path, $override = false)
    {
        $path = trim($path, '/');
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $type  = finfo_file($finfo, $source);
        finfo_close($finfo);

        $response = $this->clientS3->putObject(array(
            'Bucket'      => $this->bucket,
            'Key'         => $path,
            'SourceFile'  => $source,
            'ACL'         => static::ACL_PUBLIC_READ,
            'ContentType' => $type,
            'CacheControl' => "max-age={$this->expires_seconds}",
            'Expires' => gmdate("D, d M Y H:i:s T", time()+$this->expires_seconds),
        ));

        return true;
    }
729336
public function uploadFile($path, $target_path)
    {
        try {
            // 保存路径
            $save_path = $this->option('root') . $target_path;
            
            // 文件夹检查
            $save_dir = dirname($save_path);
            if (! is_dir($save_dir)) {
                mkdir($save_dir, 0777, true);
            }
            
            // 移动文件
            rename($path, $save_path);
            
            // 拼接链接
            $url = $this->option('url') . $target_path;
            return Format::formatResult(1, '上传成功', $url);
        } catch (\Exception $e) {
            return Format::formatResult(0, '上传文件发生意外');
        }
    }
295752
public function upload($targetDirectory = null) {
		$helper = new FileUpload();

		if ($targetDirectory !== null) {
			$helper->withTargetDirectory($this->getStoragePath($targetDirectory));
		}

		return $helper;
	}
487446
public function copyFile($origFilePath, $targetFilePath, $publicAccess = true)
	{
		$origFilePath = str_replace('//', '/', $origFilePath);
		$targetFilePath = str_replace('//', '/', $targetFilePath);
		$result = $this->s3Client->copyObject(array(
			'Bucket' => $this->getBucket(),
			'CopySource' => $origFilePath,
			'Key'    => $targetFilePath,
			'ACL'    => $publicAccess ? self::PUBLIC_READ : self::PRIVATE_ACCESS
		));

		return $result;
	}
438702
public function load($sourcePath, $targetPath)
  {
    $mapper = new AssetMapper();
    $mapper->map($sourcePath, $targetPath);

    return $mapper;
  }