Classes/S3Storage.php
/**
     * Imports a resource (file) from the given URI or PHP resource stream into this storage.
     *
     * On a successful import this method returns a Resource object representing the newly
     * imported persistent resource.
     *
     * @param string | resource $source The URI (or local path and filename) or the PHP resource stream to import the resource from
     * @param string $collectionName Name of the collection the new Resource belongs to
     * @return PersistentResource A resource object representing the imported resource
     * @throws StorageException
     * @throws \Neos\Flow\Utility\Exception
     * @throws FilesException
     * @throws \Exception
     */
Imports a resource (file) from the given URI or PHP resource stream into this storage.
On a successful import this method returns a Resource object representing the newly
imported persistent resource.


Imports a resource ( file ) from the given URI or PHP resource stream into this storage . On a successful import this method returns a Resource object representing the newly imported persistent resource .
public function importResource($source, $collectionName): PersistentResource
    {
        $temporaryTargetPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Flownative_Aws_S3_' . Algorithms::generateRandomToken(12) . '.tmp';
        if (is_resource($source)) {
            try {
                $target = fopen($temporaryTargetPathAndFilename, 'wb');
                stream_copy_to_stream($source, $target);
                fclose($target);
            } catch (\Exception $e) {
                throw new Exception(sprintf('Could not import the content stream to temporary file "%s".', $temporaryTargetPathAndFilename), 1428915486);
            }
        } else {
            try {
                copy($source, $temporaryTargetPathAndFilename);
            } catch (\Exception $e) {
                throw new Exception(sprintf('Could not copy the file from "%s" to temporary file "%s".', $source, $temporaryTargetPathAndFilename), 1428915488);
            }
        }
        return $this->importTemporaryFile($temporaryTargetPathAndFilename, $collectionName);
    }
public function importResource ( $ source , $ collectionName ) : PersistentResource { $ temporaryTargetPathAndFilename = $ this -> environment -> getPathToTemporaryDirectory ( ) . 'Flownative_Aws_S3_' . Algorithms :: generateRandomToken ( 12 ) . '.tmp' ; if ( is_resource ( $ source ) ) { try { $ target = fopen ( $ temporaryTargetPathAndFilename , 'wb' ) ; stream_copy_to_stream ( $ source , $ target ) ; fclose ( $ target ) ; } catch ( \ Exception $ e ) { throw new Exception ( sprintf ( 'Could not import the content stream to temporary file "%s".' , $ temporaryTargetPathAndFilename ) , 1428915486 ) ; } } else { try { copy ( $ source , $ temporaryTargetPathAndFilename ) ; } catch ( \ Exception $ e ) { throw new Exception ( sprintf ( 'Could not copy the file from "%s" to temporary file "%s".' , $ source , $ temporaryTargetPathAndFilename ) , 1428915488 ) ; } } return $ this -> importTemporaryFile ( $ temporaryTargetPathAndFilename , $ collectionName ) ; }
Imports a resource (file) from the given URI or PHP resource stream into this storage.
Imports a resource ( file ) from the given URI or PHP resource stream into this storage .