filestack/mixins/CommonMixin.php
protected function handleResponseCreateFilelink($response)
    {
        $status_code = $response->getStatusCode();

        if ($status_code !== 200) {
            throw new FilestackException($response->getBody(), $status_code);
        }

        $json_response = json_decode($response->getBody(), true);
        $url = $json_response['url'];
        $file_handle = substr($url, strrpos($url, '/') + 1);

        $filelink = new Filelink($file_handle, $this->api_key, $this->security);
        $filelink->metadata['filename'] = $json_response['filename'];
        $filelink->metadata['size'] = $json_response['size'];
        $filelink->metadata['mimetype'] = 'unknown';

        if (isset($json_response['type'])) {
            $filelink->metadata['mimetype'] = $json_response['type'];
        } elseif (isset($json_response['mimetype'])) {
            $filelink->metadata['mimetype'] = $json_response['mimetype'];
        }

        return $filelink;
    }
protected function handleResponseCreateFilelink($response)
    {
        $status_code = $response->getStatusCode();

        if ($status_code !== 200) {
            throw new FilestackException($response->getBody(), $status_code);
        }

        $json_response = json_decode($response->getBody(), true);
        $url = $json_response['url'];
        $file_handle = substr($url, strrpos($url, '/') + 1);

        $filelink = new Filelink($file_handle, $this->api_key, $this->security);
        $filelink->metadata['filename'] = $json_response['filename'];
        $filelink->metadata['size'] = $json_response['size'];
        $filelink->metadata['mimetype'] = 'unknown';

        if (isset($json_response['type'])) {
            $filelink->metadata['mimetype'] = $json_response['type'];
        } elseif (isset($json_response['mimetype'])) {
            $filelink->metadata['mimetype'] = $json_response['mimetype'];
        }

        return $filelink;
    }
protected function handleResponseCreateFilelink ( $ response ) { $ status_code = $ response -> getStatusCode ( ) ; if ( $ status_code !== 200 ) { throw new FilestackException ( $ response -> getBody ( ) , $ status_code ) ; } $ json_response = json_decode ( $ response -> getBody ( ) , true ) ; $ url = $ json_response [ 'url' ] ; $ file_handle = substr ( $ url , strrpos ( $ url , '/' ) + 1 ) ; $ filelink = new Filelink ( $ file_handle , $ this -> api_key , $ this -> security ) ; $ filelink -> metadata [ 'filename' ] = $ json_response [ 'filename' ] ; $ filelink -> metadata [ 'size' ] = $ json_response [ 'size' ] ; $ filelink -> metadata [ 'mimetype' ] = 'unknown' ; if ( isset ( $ json_response [ 'type' ] ) ) { $ filelink -> metadata [ 'mimetype' ] = $ json_response [ 'type' ] ; } elseif ( isset ( $ json_response [ 'mimetype' ] ) ) { $ filelink -> metadata [ 'mimetype' ] = $ json_response [ 'mimetype' ] ; } return $ filelink ; }
Handle a Filestack response and create a filelink object

@param   Http\Message\Response    $response    response object

@throws FilestackException   if statuscode is not OK

@return Filestack\Filelink
Handle a Filestack response and create a filelink object