Classes/Command/S3CommandController.php
/**
     * Upload a file to a bucket
     *
     * This command uploads the file specified by <b>file</b> to the bucket
     * specified by <bucket>. The bucket must exist already in order to upload
     * the file.
     *
     * @param string $bucket Name of the bucket
     * @param string $file Full path leading to the file to upload
     * @param string $key Key to use for the uploaded object, for example "Coffee.jpg" or "MyPictures/Machines/Coffee.jpg". If not specified, the original filename is used.
     * @return void
     */
Upload a file to a bucket
This command uploads the file specified by file to the bucket
specified by . The bucket must exist already in order to upload
the file.

@param string $bucket Name of the bucket
@param string $file Full path leading to the file to upload
@param string $key Key to use for the uploaded object, for example "Coffee.jpg" or "MyPictures/Machines/Coffee.jpg". If not specified, the original filename is used.
@return void
Upload a file to a bucket This command uploads the file specified by file to the bucket specified by . The bucket must exist already in order to upload the file . @param string $bucket Name of the bucket @param string $file Full path leading to the file to upload @param string $key Key to use for the uploaded object for example " Coffee . jpg " or " MyPictures / Machines / Coffee . jpg " . If not specified the original filename is used . @return void
public function uploadCommand(string $bucket, string $file, string $key = ''): void
    {
        if (!file_exists($file)) {
            $this->outputLine('The specified file does not exist.');
            $this->quit(1);
        }
        if ($key === '') {
            $key = basename($file);
        }
        try {
            $this->s3Client->putObject([
                'Key' => $key,
                'Bucket' => $bucket,
                'Body' => fopen('file://' . realpath($file), 'rb')
            ]);
        } catch (\Exception $e) {
            $this->outputLine('Could not upload %s to %s::%s – %s', [$file, $bucket, $key, $e->getMessage()]);
            $this->quit(1);
        }
        $this->outputLine('Successfully uploaded %s to %s::%s.', [$file, $bucket, $key]);
    }
public function uploadCommand ( string $ bucket , string $ file , string $ key = '' ) : void { if ( ! file_exists ( $ file ) ) { $ this -> outputLine ( 'The specified file does not exist.' ) ; $ this -> quit ( 1 ) ; } if ( $ key === '' ) { $ key = basename ( $ file ) ; } try { $ this -> s3Client -> putObject ( [ 'Key' => $ key , 'Bucket' => $ bucket , 'Body' => fopen ( 'file://' . realpath ( $ file ) , 'rb' ) ] ) ; } catch ( \ Exception $ e ) { $ this -> outputLine ( 'Could not upload %s to %s::%s – %s',  [ f i le,  $ u cket,  $ e y,  $ - > ge tMessage() ] ) ; $ this -> quit ( 1 ) ; } $ this -> outputLine ( 'Successfully uploaded %s to %s::%s.' , [ $ file , $ bucket , $ key ] ) ; }
Upload a file to a bucket
 This command uploads the file specified by <b>file</b> to the bucket
 specified by <bucket>.
Upload a file to a bucket This command uploads the file specified by <b > file< / b > to the bucket specified by <bucket > .