Uploads file to s3
@param $filePath
@param string $contentType
@return string
518584
public function upload($filePath, $contentType = 'text/plain')
    {
        $s3FileName = $this->getFilePathAndUniquePrefix() . basename($filePath);
        list($bucket, $prefix) = explode('/', $this->s3path, 2);

        $this->s3client->putObject([
            'Bucket' => $bucket,
            'Key' => (empty($prefix) ? '' : (trim($prefix, '/') . '/')) . $s3FileName,
            'ContentType' => $contentType,
            'ACL' => 'private',
            'ServerSideEncryption' => 'AES256',
            'SourceFile' => $filePath,
        ]);

        return $this->withUrlPrefix($s3FileName);
    }
566293
private function dispatchEvent($eventType, $filePath)
    {
        if (null !== $this->eventDispatcher) {
            $relativePath = $this->fs->makePathRelative(dirname($filePath), $this->root) . basename($filePath);
            $this->eventDispatcher->dispatch(
                $eventType,
                new ResourceEvent($relativePath, $this->httpRoot, $this->root)
            );

            if (null !== $this->imagineConfig) {
                if (false !== strpos($relativePath, '/../') || 0 === strpos($relativePath, '../')) {
                    // outside web root, stop.
                    return;
                }

                // Create events for the imagine cache as well.

                /** @var CacheManager $cacheManager */
                /** @var FilterConfiguration $filterConfig */
                list ($cacheManager, $filterConfig) = $this->imagineConfig;
                $webPath = $this->httpRoot . '/' . $relativePath;
                $cacheManager->remove($webPath);

                foreach ($filterConfig->all() as $name => $filter) {
                    $url = $cacheManager->resolve($webPath, $name);

                    // this weird construct is here because the imagine cache manager generates absolute urls
                    // even though they're local for some unapparent reason.
                    $relativeUrl = parse_url($url, PHP_URL_PATH);
                    $url = $this->fs->makePathRelative(dirname($relativeUrl), $this->httpRoot) . basename($relativeUrl);

                    if (false === strpos($url, '../')) {
                        $this->eventDispatcher->dispatch(
                            $eventType,
                            new ResourceEvent($url, $this->httpRoot, $this->root)
                        );
                    }
                }
            }
        }
    }
849657
public function uploadFile($fileName, $fileLocation, \Google_Service_Drive_DriveFile $folder = null, $uploadType = 'media')
    {
        //Insert a file
        $file = new \Google_Service_Drive_DriveFile();
        $file->setTitle($fileName);
        $fileInfo = new \finfo(FILEINFO_MIME_TYPE);
        $mimeType = $fileInfo->file($fileLocation);
        $file->setDescription($fileName);
        $file->setMimeType($mimeType);
        if ($folder !== null) {
            $parent = new \Google_Service_Drive_ParentReference();
            $parent->setId($folder->getId());
            $file->setParents(array($parent));
        }
        $data = file_get_contents($fileLocation);
        try {
            return $this->service->files->insert($file, array(
               'data'       => $data,
               'mimeType'   => $file->getMimeType(),
               'uploadType' => $uploadType,
            ));
        } catch (\Google_Service_Exception $obj_ex) {
            $this->service->getClient()->getLogger()->error($obj_ex->getMessage());
            return false;
        }
    }
473813
public function asset($encPath, $contentType, Filesystem $fileSystem)
    {
        return $this->service->asset($encPath, $contentType, $fileSystem);
    }
1325133
public function uploadString($name, $content, $contentType = 'text/plain')
    {
        $fileName = $this->path . '/' . $this->getFilePathAndUniquePrefix() . $name;

        if ($contentType === 'application/json') {
            $content = Json::prettyPrint($content);
        }

        (new Filesystem)->dumpFile($fileName, $content);

        return $fileName;
    }
255699
public function download($filePath)
    {
        $urlParts = parse_url($filePath);
        $rootDir = null;

        if (!is_null($this->rootDir)) {
            $rootDir = $this->rootDir;
        } else {
            $rootDir = CYGNITE_BASE.DS;
        }

        $filePath = $rootDir.str_replace('/', DS, str_replace('/'.ROOTDIR.'/', '', $urlParts['path']));

        if (is_null($this->filePath) && $filePath != '') {
            $this->filePath = $filePath;
        }

        $isSetFileType = $this->setMimeType($this->filePath);

        if ($isSetFileType) {
            $this->setHeaders();
        }
        //$this->filePath
    }
843782
public static function uploadSlice($filePath, $bucket=Conf::BUCKET, $fileid = '', $sliceSize = 0, $session = null,$userid = 0, $magicContext = null,   $params = array()) {  
        $res = self::upload_slice_impl($filePath, $bucket, $fileid, $userid, $magicContext, $sliceSize, $session, $params);      
        if(false === $res)
        {
            $data = array();
        }else{
            $data = $res;
        }

         return array('code' =>self::$_messageInfo["code"], 
                         'message' => self::$_messageInfo["message"],
                         'data' => $data);
    }
114064
private static function parseFile($filePath = '')
    {
        $supportFileType = array();
        $supportFileType = array_merge($supportFileType, self::supportFilePHP());
        $supportFileType = array_merge($supportFileType, self::supportFileYAML());
        foreach ($supportFileType as $value) {
            $file = sprintf('%s.%s', $filePath, $value);
            if (is_file($file)) {
                if (in_array($value, self::supportFilePHP())) {
                    return require($file);
                }
                if (in_array($value, self::supportFileYAML())) {
                    return Yaml::parse(file_get_contents($file));
                }
            }
        }
        return null;
    }
532281
public function download($fileName, $contentType, $contents)
    {
        $body = $this->builder->messages()->stringStream($contents);
        return $this->downloadResponse($fileName, $contentType, $body);
    }
549038
@Override
    public boolean upload(String filePath) {
        WebLocator upload = new WebLocator(this).setTag("input").setType("file");
        return upload(upload, filePath);
    }
1154653
def upload(s3_conn, filepath, s3_path):
    
    bucket_name, prefix = split_s3_path(s3_path)
    bucket = s3_conn.get_bucket(bucket_name)
    filename = os.path.basename(filepath)

    key = boto.s3.key.Key(
        bucket=bucket,
        name='{}/{}'.format(prefix, filename)
    )
    logging.info('uploading from %s to %s', filepath, key)
    key.set_contents_from_filename(filepath)
472544
public function createFileOnDFS( $filePath, $contents )
    {
        $this->accumulatorStart();

        $filePath = $this->makeDFSPath( $filePath );
        $ret = $this->createFile( $filePath, $contents, false );

        $this->accumulatorStop();

        return $ret;
    }
192979
public function downloadAction($filePath)
    {
        $response = new Response();

        if (!$this->authenticate($filePath)) {
            return $response->setStatusCode(Response::HTTP_UNAUTHORIZED);
        }

        $content = $this->fileSystem->load($filePath);

        $response->headers->set('Content-Type', 'mime/type');
        $response->headers->set('Content-Disposition', 'attachment;filename="' . $filePath);

        $response->setContent($content);

        return $response;
    }
226943
public function store(string $filePath = null, string $disk = null, string $writerType = null, $diskOptions = [])
    {
        $filePath = $filePath ?? $this->filePath ?? null;

        if (null === $filePath) {
            throw NoFilePathGivenException::export();
        }

        return $this->getExporter()->store(
            $this,
            $filePath,
            $disk ?? $this->disk ?? null,
            $writerType ?? $this->writerType ?? null,
            $diskOptions ?? $this->diskOptions ?? []
        );
    }
697501
public function uploadShopImage($filePath, $fileName = null)
    {
        $fileName === null && $fileName = pathinfo($filePath, PATHINFO_BASENAME);
        $result = $this->httpRaw(self::WECHAT_SHOP_IMAGE_UPLOAD_URL .
            'access_token=' . $this->getAccessToken() . '&filename=' . $fileName, file_get_contents($filePath));
        return isset($result['errmsg']) && $result['errmsg'] == 'success' ? $result['image_url'] : false;
    }
601145
public static function addFile($filePath, $extensionToFind = '.php')
    {
		if (!$filePath instanceof SplFileInfo) {
			$filePath = new SplFileInfo($filePath);
        }

		$firstChar = substr($filePath->getBasename(), 0, 1);
		$extension = substr($filePath->getFilename(), strlen($extensionToFind)*-1);
		$className = $filePath->getBasename($extension);
		if ($extension == $extensionToFind && $firstChar === strtoupper($firstChar)) {
			self::addClass($className, $filePath->getRealPath());
		}
	}
1205810
public static function getXmlContentFromFile ($filePath)
    {
        // Detect media type
        $finfo         = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
        $fileMediaType = finfo_file($finfo, $filePath);
        finfo_close($finfo);

        // Act upon detected media type
        switch ($fileMediaType) {
            case 'application/xml':
                $fileContent = file_get_contents($filePath);
                break;
            case 'application/x-gzip':
                $fileContent = self::gunzip($filePath);
                break;
            case 'application/zip':
                $fileContent = self::unzip($filePath);
                break;
            default:
                throw new Exception("Unsupported file media type: $fileMediaType");
        }

        return $fileContent;
    }