Classes/S3Storage.php
/**
     * Imports a resource (file) as specified in the given upload info array as a
     * persistent resource.
     *
     * On a successful import this method returns a Resource object representing
     * the newly imported persistent resource.
     *
     * @param array $uploadInfo An array detailing the resource to import (expected keys: name, tmp_name)
     * @param string $collectionName Name of the collection this uploaded resource should be part of
     * @return PersistentResource A resource object representing the imported resource
     * @throws StorageException
     * @throws \Neos\Flow\Utility\Exception
     * @throws FilesException
     * @throws \Exception
     * @api
     */
Imports a resource (file) as specified in the given upload info array as a
persistent resource.

On a successful import this method returns a Resource object representing
the newly imported persistent resource.


Imports a resource ( file ) as specified in the given upload info array as a persistent resource . On a successful import this method returns a Resource object representing the newly imported persistent resource .
public function importUploadedResource(array $uploadInfo, string $collectionName): PersistentResource
    {
        $pathInfo = pathinfo($uploadInfo['name']);
        $originalFilename = $pathInfo['basename'];
        $sourcePathAndFilename = $uploadInfo['tmp_name'];
        if (!file_exists($sourcePathAndFilename)) {
            throw new Exception(sprintf('The temporary file "%s" of the file upload does not exist (anymore).', $sourcePathAndFilename), 1428909075);
        }
        $newSourcePathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Flownative_Aws_S3_' . Algorithms::generateRandomToken(12) . '.tmp';
        if (move_uploaded_file($sourcePathAndFilename, $newSourcePathAndFilename) === false) {
            throw new Exception(sprintf('The uploaded file "%s" could not be moved to the temporary location "%s".', $sourcePathAndFilename, $newSourcePathAndFilename), 1428909076);
        }
        $sha1Hash = sha1_file($newSourcePathAndFilename);
        $resource = new PersistentResource();
        $resource->setFilename($originalFilename);
        $resource->setCollectionName($collectionName);
        $resource->setFileSize(filesize($newSourcePathAndFilename));
        $resource->setSha1($sha1Hash);
        $this->s3Client->putObject([
            'Bucket' => $this->bucketName,
            'Body' => fopen($newSourcePathAndFilename, 'rb'),
            'ContentLength' => $resource->getFileSize(),
            'ContentType' => $resource->getMediaType(),
            'Key' => $this->keyPrefix . $sha1Hash
        ]);
        return $resource;
    }
public function importUploadedResource ( array $ uploadInfo , string $ collectionName ) : PersistentResource { $ pathInfo = pathinfo ( $ uploadInfo [ 'name' ] ) ; $ originalFilename = $ pathInfo [ 'basename' ] ; $ sourcePathAndFilename = $ uploadInfo [ 'tmp_name' ] ; if ( ! file_exists ( $ sourcePathAndFilename ) ) { throw new Exception ( sprintf ( 'The temporary file "%s" of the file upload does not exist (anymore).' , $ sourcePathAndFilename ) , 1428909075 ) ; } $ newSourcePathAndFilename = $ this -> environment -> getPathToTemporaryDirectory ( ) . 'Flownative_Aws_S3_' . Algorithms :: generateRandomToken ( 12 ) . '.tmp' ; if ( move_uploaded_file ( $ sourcePathAndFilename , $ newSourcePathAndFilename ) === false ) { throw new Exception ( sprintf ( 'The uploaded file "%s" could not be moved to the temporary location "%s".' , $ sourcePathAndFilename , $ newSourcePathAndFilename ) , 1428909076 ) ; } $ sha1Hash = sha1_file ( $ newSourcePathAndFilename ) ; $ resource = new PersistentResource ( ) ; $ resource -> setFilename ( $ originalFilename ) ; $ resource -> setCollectionName ( $ collectionName ) ; $ resource -> setFileSize ( filesize ( $ newSourcePathAndFilename ) ) ; $ resource -> setSha1 ( $ sha1Hash ) ; $ this -> s3Client -> putObject ( [ 'Bucket' => $ this -> bucketName , 'Body' => fopen ( $ newSourcePathAndFilename , 'rb' ) , 'ContentLength' => $ resource -> getFileSize ( ) , 'ContentType' => $ resource -> getMediaType ( ) , 'Key' => $ this -> keyPrefix . $ sha1Hash ] ) ; return $ resource ; }
Imports a resource (file) as specified in the given upload info array as a
 persistent resource.
Imports a resource ( file ) as specified in the given upload info array as a persistent resource .