Package: s3-client
s3-client - Example python script to work with S3Installationpipinstalls3-clientAuthorizationAuthorization is performed using environment variables:AWS_ACCESS_KEY_ID-  Specifies an AWS access keyAWS_SECRET_ACCESS_KEY- Specifies the secret key associated with the access key. This is essentially the "password" for the access key.Usage:$s3-client
usage:s3-client[-h][-d][-eENDPOINT][-rREGION_NAME]{listbuckets,listobj,deleteobj,metadataobj,upload,download}...

S3Clientsamplescript

optionalarguments:-h,--helpshowthishelpmessageandexit-d,--debugdebugflag-eENDPOINT,--endpointENDPOINTS3endpointURL-rREGION_NAME,--regionREGION_NAMES3RegionName

Commands:{listbuckets,listobj,deleteobj,metadataobj,upload,download}listbucketsListallbucketslistobjListobjectsinabucketdeleteobjDeleteobjectinabucketmetadataobjListobjectmetadatauploadUploadfilestobucketdownloadDownloadfilesfrombucketExampleofuse:s3-clientlistbucketss3-client-rus-east-1listbucketss3-client-ehttps://s3.amazonaws.comlistobjmy_bucket-ts3-client-ehttps://s3.amazonaws.comuploadmy_bucket-ffile1s3-client-ehttps://s3.amazonaws.comuploadmy_bucket-dmydirExample:List buckets$s3-client-ehttps://s3.amazonaws.comlistbuckets
Bucket_Name:test-script1Creation_Date:2019-03-2219:40:36.379000+00:00versioning_status:None
Bucket_Name:test-script2Creation_Date:2019-03-2219:50:35.706000+00:00versioning_status:EnabledUpload file(s)$s3-client-ehttps://s3.amazonaws.comuploadmy_bucket-fmy_file.csv
Uploadingfilemy_file.csvwithobjectnamemy_file.csv
datatransferred:100%|█████████████████████████████████████████████████████████████|8.39M/8.39M[00:16<00:00,520kB/s]-Elapsedtime16.1471seconds-Uploadcompletedsuccessfully


$s3-client-ehttps://s3.amazonaws.comuploadmy_bucket-dmydir/--nopbar
Uploadingfilemydir/test2withobjectnamemydir/test2-Elapsedtime0.1007seconds-Uploadcompletedsuccessfully
Uploadingfilemydir/test1withobjectnamemydir/test1-Elapsedtime0.1183seconds-Uploadcompletedsuccessfully
Uploadingfilemydir/internal/test3withobjectnamemydir/internal/test3-Elapsedtime0.1277seconds-Uploadcompletedsuccessfully
Uploadingfilemydir/internal/deep/test4withobjectnamemydir/internal/deep/test4-Elapsedtime0.1114seconds-Uploadcompletedsuccessfully
Uploadingfilemydir/internal/deep/test5withobjectnamemydir/internal/deep/test5-Elapsedtime0.0683seconds-UploadcompletedsuccessfullyList objects in a bucket$s3-clientlistobj-h
usage:s3-clientlistobj[-h][-lLIMIT][-t][-pPREFIX][-v]bucket

positionalarguments:bucketBucketName

optionalarguments:-h,--helpshowthishelpmessageandexit-lLIMIT,--limitLIMITLimitthenumberofobjectsreturned-t,--tableShowoutputastable-pPREFIX,--prefixPREFIXOnlyobjectswithspecificprefix-v,--versionsShowallobjectversions$s3-client-ehttps://s3.amazonaws.comlistobjmy_bucket
key:mydir/internal/deep/test4size:10storage_class:STANDARDe_tag:"d41d8cd98f00b204e9800998ecf8427e"last_modified:2020-08-2116:40:42.790000+00:00
key:mydir/internal/deep/test5size:203storage_class:STANDARDe_tag:"7c41d8cd98f00b204e9800998ecf8427"last_modified:2020-08-2116:40:42.894000+00:00
key:mydir/internal/test3size:42storage_class:STANDARDe_tag:"9acbdfd98f00b204e9100998ecf8423a"last_modified:2020-08-2116:40:42.655000+00:00
key:mydir/test1size:1031storage_class:STANDARDe_tag:"8acffca98f00b204e98a0821ecf8447e"last_modified:2020-08-2116:40:42.538000+00:00
key:mydir/test2size:121storage_class:STANDARDe_tag:"d3ab64d98f00b20401800998ecf8438b"last_modified:2020-08-2116:40:42.429000+00:00


$s3-client-ehttps://s3.amazonaws.comlistobjmy_bucket-t|key|size|storage_class|e_tag|last_modified||---------------------------|--------|-----------------|------------------------------------|----------------------------------||mydir/internal/deep/test4|10|STANDARD|"d41d8cd98f00b204e9800998ecf8427e"|2020-08-2116:40:42.790000+00:00||mydir/internal/deep/test5|203|STANDARD|"7c41d8cd98f00b204e9800998ecf8427"|2020-08-2116:40:42.894000+00:00||mydir/internal/test3|42|STANDARD|"9acbdfd98f00b204e9100998ecf8423a"|2020-08-2116:40:42.655000+00:00||mydir/test1|1031|STANDARD|"8acffca98f00b204e98a0821ecf8447e"|2020-08-2116:40:42.538000+00:00||mydir/test2|121|STANDARD|"d3ab64d98f00b20401800998ecf8438b"|2020-08-2116:40:42.429000+00:00|Download objects$s3-client-ehttps://s3.amazonaws.comdownload-h
usage:s3-clientdownload[-h][--nopbar][-lLOCALDIR][-o][-vVERSIONID](-fFILENAME|-pPREFIX)bucket

positionalarguments:bucketBucketName

optionalarguments:-h,--helpshowthishelpmessageandexit--nopbarDisableprogressbar-lLOCALDIR,--localdirLOCALDIRLocaldirectorytosavedownloadedfile.Defaultcurrentdirectory-o,--overwriteOverwritelocaldestinationfileifitexists.Defaultfalse-vVERSIONID,--versionidVERSIONIDObjectversionid-fFILENAME,--fileFILENAMEDownloadaspecificfile-pPREFIX,--prefixPREFIXDownloadrecursivelyallfileswithaprefix.$s3-client-ehttps://s3.amazonaws.comdownloadmy_bucket-fmydir/test1
Error:File./mydir/test1exist.Removeitfromlocaldrivetodownload.

$s3-client-ehttps://s3.amazonaws.comdownloadmy_bucket-fmydir/test1--overwrite
Downloadingobjectmydir/test1topath./mydir/test1
datatransferred:100%|███████████████████████████████████████████████|5.24M/5.24M[00:11<00:00,468kB/s]-Elapsedtime11.3103seconds-Downloadcompletedsuccessfully$s3-client-ehttps://s3.amazonaws.comdownloadmy_bucket-fmydir/test1-l/tmp/
Downloadingobjectmydir/test1topath/tmp/mydir/test1
datatransferred:100%|███████████████████████████████████████████████|5.24M/5.24M[00:11<00:00,468kB/s]-Elapsedtime11.3103seconds-Downloadcompletedsuccessfully

$ls/tmp/mydir/test1
/tmp/mydir/test1