Xc@sddlZddlZddlZddlZddlZddlmZddlZddlm Z ddl Z ddl m Z ddl Zde e fdYZdefdYZdS( iN(tArg(tFileTransferProgressBarMixin(t S3Requestt PutObjectcBseZdZeddddd(ddeddddd(dd ed d edd(dd ed dd(dd)eddd(ddeddddddddddd(dd ed!dejgZd"Z d#Z d$Z d%Z d&Z dd'ZRS(*sUpload an object to the server Note that uploading a large file to a region other than the one the bucket is may result in "Broken pipe" errors or other connection problems that this program cannot detect.tsourcetmetavartFILEtroute_tothelpsfile to upload (required)tdests BUCKET/KEYs6bucket and key name to upload the object to (required)s--sizettypesPthe number of bytes to upload (required when reading from stdin)s--acltchoicestprivates public-readspublic-read-writesauthenticated-readsbucket-owner-readsbucket-owner-full-controls aws-exec-reads --mime-types%MIME type for the file being uploadeds--retrytretriestactiont store_consttconstitdefaultis'retry interrupted uploads up to 5 timess--progressbar-labeltPUTcKs,tj||d|_tj|_dS(N(Rt__init__tNonetlast_upload_errort threadingtLockt_lock(tselftkwargs((sC/usr/lib/python2.7/site-packages/euca2ools/commands/s3/putobject.pyR@s cCs]tj||jddkri|jjddkrMtjjdntt j |jd}nt |jdt j rtj|jdd|jjd}nJ|jjddkrtjjdnt|jd|jd}||jd<|jdjd\}}}|s>tjjdn|sYtjjd ndS( NRt-tsizes0argument --size is required when uploading stdins8argument --size is required when uploading a file objectR t/s)destination bucket name must be non-emptys&destination key name must be non-empty(Rt configuretargstgetRtrequestbuildert exceptionst ArgumentErrort_FileObjectExtenttsyststdint isinstancetsixt string_typest from_filenamet partition(RRtbuckett_tkey((sC/usr/lib/python2.7/site-packages/euca2ools/commands/s3/putobject.pyRFs*   %      cCsf|jd|_|jjdr9|jd|jds        }