o ckF[yã@s<ddlZddlZddlmZddlmZGdd„deƒZdS)éN)Ú RawMessage)ÚSQSDecodeErrorcsNeZdZdZd‡fdd„ Zdd„Zdd„Zd d „Zd d „Z‡fd d„Z ‡Z S)Ú BigMessagea± The BigMessage class provides large payloads (up to 5GB) by storing the payload itself in S3 and then placing a reference to the S3 object in the actual SQS message payload. To create a BigMessage, you should create a BigMessage object and pass in a file-like object as the ``body`` param and also pass in the an S3 URL specifying the bucket in which to store the message body:: import boto.sqs from boto.sqs.bigmessage import BigMessage sqs = boto.sqs.connect_to_region('us-west-2') queue = sqs.get_queue('myqueue') fp = open('/path/to/bigmessage/data') msg = BigMessage(queue, fp, 's3://mybucket') queue.write(msg) Passing in a fully-qualified S3 URL (e.g. s3://mybucket/foo) is interpreted to mean that the body of the message is already stored in S3 and the that S3 URL is then used directly with no content uploaded by BigMessage. Ncs||_tt|ƒ ||¡dS©N)Ús3_urlÚsuperrÚ__init__)ÚselfÚqueueÚbodyr©Ú __class__©ú5/usr/lib/python3/dist-packages/boto/sqs/bigmessage.pyr8szBigMessage.__init__cCsld}}|r2| d¡r+|dd… dd¡}|d}t|ƒdkr'|dr'|d}||fSd}t||ƒ‚||fS)Nzs3://éú/érz(s3_url parameter should start with s3://)Ú startswithÚsplitÚlenr)r rÚ bucket_nameÚkey_nameÚ s3_componentsÚmsgrrrÚ_get_bucket_key<s  þ zBigMessage._get_bucket_keycCs`| |j¡\}}|r|r|jSt ¡}t ¡}| |¡}| |¡}| |¡d||f|_|jS)a  :type value: file-like object :param value: A file-like object containing the content of the message. The actual content will be stored in S3 and a link to the S3 object will be stored in the message body. z s3://%s/%s) rrÚuuidÚuuid4ÚbotoÚ connect_s3Ú get_bucketÚnew_keyÚset_contents_from_file)r ÚvaluerrÚs3_connÚ s3_bucketÚkeyrrrÚencodeNs   zBigMessage.encodecCsH| |¡\}}|r|rt ¡}| |¡}| |¡}|Sd|}t||ƒ‚)NzUnable to decode S3 URL: %s)rrrrÚget_keyr)r rrrr#r$r%rrrrÚ_get_s3_objectas   zBigMessage._get_s3_objectcCs||_| |¡}| ¡Sr)rr(Úget_contents_as_string)r r"r%rrrÚdecodels zBigMessage.decodecs,|jr | |j¡}| ¡tt|ƒ ¡dSr)rr(Údeleterr)r r%r rrr+qs zBigMessage.delete)NNN) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr&r(r*r+Ú __classcell__rrr rrs r)rrÚboto.sqs.messagerÚboto.exceptionrrrrrrÚs