Classes/S3Storage.php
/**
     * Imports a resource from the given string content into this storage.
     *
     * On a successful import this method returns a Resource object representing the newly
     * imported persistent resource.
     *
     * The specified filename will be used when presenting the resource to a user. Its file extension is
     * important because the resource management will derive the IANA Media Type from it.
     *
     * @param string $content The actual content to import
     * @param string $collectionName Name of the collection the new Resource belongs to
     * @return PersistentResource A resource object representing the imported resource
     * @throws \Exception
     * @api
     */
Imports a resource from the given string content into this storage.
On a successful import this method returns a Resource object representing the newly
imported persistent resource.

The specified filename will be used when presenting the resource to a user. Its file extension is
important because the resource management will derive the IANA Media Type from it.


Imports a resource from the given string content into this storage . On a successful import this method returns a Resource object representing the newly imported persistent resource . The specified filename will be used when presenting the resource to a user . Its file extension is important because the resource management will derive the IANA Media Type from it .
public function importResourceFromContent($content, $collectionName): PersistentResource
    {
        $sha1Hash = sha1($content);
        $filename = $sha1Hash;
        $resource = new PersistentResource();
        $resource->setFilename($filename);
        $resource->setFileSize(strlen($content));
        $resource->setCollectionName($collectionName);
        $resource->setSha1($sha1Hash);
        $this->s3Client->putObject([
            'Bucket' => $this->bucketName,
            'Body' => $content,
            'ContentLength' => $resource->getFileSize(),
            'ContentType' => $resource->getMediaType(),
            'Key' => $this->keyPrefix . $sha1Hash
        ]);
        return $resource;
    }
public function importResourceFromContent ( $ content , $ collectionName ) : PersistentResource { $ sha1Hash = sha1 ( $ content ) ; $ filename = $ sha1Hash ; $ resource = new PersistentResource ( ) ; $ resource -> setFilename ( $ filename ) ; $ resource -> setFileSize ( strlen ( $ content ) ) ; $ resource -> setCollectionName ( $ collectionName ) ; $ resource -> setSha1 ( $ sha1Hash ) ; $ this -> s3Client -> putObject ( [ 'Bucket' => $ this -> bucketName , 'Body' => $ content , 'ContentLength' => $ resource -> getFileSize ( ) , 'ContentType' => $ resource -> getMediaType ( ) , 'Key' => $ this -> keyPrefix . $ sha1Hash ] ) ; return $ resource ; }
Imports a resource from the given string content into this storage.
Imports a resource from the given string content into this storage .