public function upload($assets)
    {
        // connect before uploading
        $connected = $this->connect();

        if (!$connected) {
            return false;
        }

        // user terminal message
        $this->console->writeln('<fg=yellow>Comparing local files and bucket...</fg=yellow>');

        $assets = $this->getFilesAlreadyOnBucket($assets);

        // upload each asset file to the CDN
        if(count($assets) > 0) {
            $this->console->writeln('<fg=yellow>Upload in progress......</fg=yellow>');
            foreach ($assets as $file) {
                try {
                    $this->console->writeln('<fg=cyan>'.'Uploading file path: '.$file->getRealpath().'</fg=cyan>');
                    $command = $this->s3_client->getCommand('putObject', [

                        // the bucket name
                        'Bucket' => $this->getBucket(),
                        // the path of the file on the server (CDN)
                        'Key' => str_replace('\\', '/', $file->getPathName()),
                        // the path of the path locally
                        'Body' => fopen($file->getRealPath(), 'r'),
                        // the permission of the file

                        'ACL' => $this->acl,
                        'CacheControl' => $this->default['providers']['aws']['s3']['cache-control'],
                        'Metadata' => $this->default['providers']['aws']['s3']['metadata'],
                        'Expires' => $this->default['providers']['aws']['s3']['expires'],
                    ]);
//                var_dump(get_class($command));exit();


                    $this->s3_client->execute($command);
                } catch (S3Exception $e) {
                    $this->console->writeln('<fg=red>'.$e->getMessage().'</fg=red>');

                    return false;
                }
            }

            // user terminal message
            $this->console->writeln('<fg=green>Upload completed successfully.</fg=green>');
        } else {
            // user terminal message
            $this->console->writeln('<fg=yellow>No new files to upload.</fg=yellow>');
        }

        return true;
    }
public function upload($assets)
    {
        // connect before uploading
        $connected = $this->connect();

        if (!$connected) {
            return false;
        }

        // user terminal message
        $this->console->writeln('<fg=yellow>Comparing local files and bucket...</fg=yellow>');

        $assets = $this->getFilesAlreadyOnBucket($assets);

        // upload each asset file to the CDN
        if(count($assets) > 0) {
            $this->console->writeln('<fg=yellow>Upload in progress......</fg=yellow>');
            foreach ($assets as $file) {
                try {
                    $this->console->writeln('<fg=cyan>'.'Uploading file path: '.$file->getRealpath().'</fg=cyan>');
                    $command = $this->s3_client->getCommand('putObject', [

                        // the bucket name
                        'Bucket' => $this->getBucket(),
                        // the path of the file on the server (CDN)
                        'Key' => str_replace('\\', '/', $file->getPathName()),
                        // the path of the path locally
                        'Body' => fopen($file->getRealPath(), 'r'),
                        // the permission of the file

                        'ACL' => $this->acl,
                        'CacheControl' => $this->default['providers']['aws']['s3']['cache-control'],
                        'Metadata' => $this->default['providers']['aws']['s3']['metadata'],
                        'Expires' => $this->default['providers']['aws']['s3']['expires'],
                    ]);
//                var_dump(get_class($command));exit();


                    $this->s3_client->execute($command);
                } catch (S3Exception $e) {
                    $this->console->writeln('<fg=red>'.$e->getMessage().'</fg=red>');

                    return false;
                }
            }

            // user terminal message
            $this->console->writeln('<fg=green>Upload completed successfully.</fg=green>');
        } else {
            // user terminal message
            $this->console->writeln('<fg=yellow>No new files to upload.</fg=yellow>');
        }

        return true;
    }
public function upload ( $ assets ) { // connect before uploading $ connected = $ this -> connect ( ) ; if ( ! $ connected ) { return false ; } // user terminal message $ this -> console -> writeln ( '<fg=yellow>Comparing local files and bucket...</fg=yellow>' ) ; $ assets = $ this -> getFilesAlreadyOnBucket ( $ assets ) ; // upload each asset file to the CDN if ( count ( $ assets ) > 0 ) { $ this -> console -> writeln ( '<fg=yellow>Upload in progress......</fg=yellow>' ) ; foreach ( $ assets as $ file ) { try { $ this -> console -> writeln ( '<fg=cyan>' . 'Uploading file path: ' . $ file -> getRealpath ( ) . '</fg=cyan>' ) ; $ command = $ this -> s3_client -> getCommand ( 'putObject' , [ // the bucket name 'Bucket' => $ this -> getBucket ( ) , // the path of the file on the server (CDN) 'Key' => str_replace ( '\\' , '/' , $ file -> getPathName ( ) ) , // the path of the path locally 'Body' => fopen ( $ file -> getRealPath ( ) , 'r' ) , // the permission of the file 'ACL' => $ this -> acl , 'CacheControl' => $ this -> default [ 'providers' ] [ 'aws' ] [ 's3' ] [ 'cache-control' ] , 'Metadata' => $ this -> default [ 'providers' ] [ 'aws' ] [ 's3' ] [ 'metadata' ] , 'Expires' => $ this -> default [ 'providers' ] [ 'aws' ] [ 's3' ] [ 'expires' ] , ] ) ; //                var_dump(get_class($command));exit(); $ this -> s3_client -> execute ( $ command ) ; } catch ( S3Exception $ e ) { $ this -> console -> writeln ( '<fg=red>' . $ e -> getMessage ( ) . '</fg=red>' ) ; return false ; } } // user terminal message $ this -> console -> writeln ( '<fg=green>Upload completed successfully.</fg=green>' ) ; } else { // user terminal message $ this -> console -> writeln ( '<fg=yellow>No new files to upload.</fg=yellow>' ) ; } return true ; }
Upload assets.

@param $assets

@return bool
Upload assets .