filestack/FilestackClient.php
public function upload($filepath, $options = [])
    {
        if (!file_exists($filepath)) {
            throw new FilestackException("File not found", 400);
        }

        $location = 's3';
        if (array_key_exists('location', $options)) {
            $location = $options['location'];
        }

        $filename = basename($filepath);
        if (array_key_exists('filename', $options)) {
            $filename = $options['filename'];
        }

        $mimetype = mime_content_type($filepath);
        if (array_key_exists('mimetype', $options)) {
            $mimetype = $options['mimetype'];
        }

        $metadata = [
            'filepath' => $filepath,
            'filename' => $filename,
            'filesize' => filesize($filepath),
            'mimetype' => $mimetype,
            'location' => $location,
        ];

        // register job
        $upload_data = $this->upload_processor->registerUploadTask($this->api_key,
            $metadata, $this->security);

        // Intelligent Ingestion option
        if (array_key_exists('intelligent', $options) &&
            $this->upload_processor->intelligenceEnabled($upload_data)) {

            $this->upload_processor->setIntelligent($options['intelligent']);
        }

        $result = $this->upload_processor->run($this->api_key,
                                               $metadata,
                                               $upload_data);

        $filelink = $result['filelink'];

        return $filelink;
    }
public function upload($filepath, $options = [])
    {
        if (!file_exists($filepath)) {
            throw new FilestackException("File not found", 400);
        }

        $location = 's3';
        if (array_key_exists('location', $options)) {
            $location = $options['location'];
        }

        $filename = basename($filepath);
        if (array_key_exists('filename', $options)) {
            $filename = $options['filename'];
        }

        $mimetype = mime_content_type($filepath);
        if (array_key_exists('mimetype', $options)) {
            $mimetype = $options['mimetype'];
        }

        $metadata = [
            'filepath' => $filepath,
            'filename' => $filename,
            'filesize' => filesize($filepath),
            'mimetype' => $mimetype,
            'location' => $location,
        ];

        // register job
        $upload_data = $this->upload_processor->registerUploadTask($this->api_key,
            $metadata, $this->security);

        // Intelligent Ingestion option
        if (array_key_exists('intelligent', $options) &&
            $this->upload_processor->intelligenceEnabled($upload_data)) {

            $this->upload_processor->setIntelligent($options['intelligent']);
        }

        $result = $this->upload_processor->run($this->api_key,
                                               $metadata,
                                               $upload_data);

        $filelink = $result['filelink'];

        return $filelink;
    }
public function upload ( $ filepath , $ options = [ ] ) { if ( ! file_exists ( $ filepath ) ) { throw new FilestackException ( "File not found" , 400 ) ; } $ location = 's3' ; if ( array_key_exists ( 'location' , $ options ) ) { $ location = $ options [ 'location' ] ; } $ filename = basename ( $ filepath ) ; if ( array_key_exists ( 'filename' , $ options ) ) { $ filename = $ options [ 'filename' ] ; } $ mimetype = mime_content_type ( $ filepath ) ; if ( array_key_exists ( 'mimetype' , $ options ) ) { $ mimetype = $ options [ 'mimetype' ] ; } $ metadata = [ 'filepath' => $ filepath , 'filename' => $ filename , 'filesize' => filesize ( $ filepath ) , 'mimetype' => $ mimetype , 'location' => $ location , ] ; // register job $ upload_data = $ this -> upload_processor -> registerUploadTask ( $ this -> api_key , $ metadata , $ this -> security ) ; // Intelligent Ingestion option if ( array_key_exists ( 'intelligent' , $ options ) && $ this -> upload_processor -> intelligenceEnabled ( $ upload_data ) ) { $ this -> upload_processor -> setIntelligent ( $ options [ 'intelligent' ] ) ; } $ result = $ this -> upload_processor -> run ( $ this -> api_key , $ metadata , $ upload_data ) ; $ filelink = $ result [ 'filelink' ] ; return $ filelink ; }
Upload a file to desired cloud service, defaults to Filestack's S3
storage.

@param string    $filepath       path to file
@param array     $options        location: specify location, possible
values are:
S3, gcs, azure, rackspace, dropbox
filename: explicitly set the filename
to store as
mimetype: explicitly set the mimetype
intelligent: set to true to use the
Intelligent Ingestion flow

@throws FilestackException   if API call fails, e.g 404 file not found

@return Filestack\Filelink or file content
Upload a file to desired cloud service defaults to Filestack s S3 storage .