ó FRTc@sRddlZddlZddlmZddlmZdefd„ƒYZdS(iĸĸĸĸN(t RawMessage(tSQSDecodeErrort BigMessagecBsMeZdZdddd„Zd„Zd„Zd„Zd„Zd„Z RS(są 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. cCs&||_tt|ƒj||ƒdS(N(ts3_urltsuperRt__init__(tselftqueuetbodyR((s@/opt/freeware/lib/python2.7/site-packages/boto/sqs/bigmessage.pyR8s cCsd}}|r†|jdƒrn|djddƒ}|d}t|ƒdkrƒ|drk|d}qkqƒq†d}t||ƒ‚n||fS(Nss3://it/iis(s3_url parameter should start with s3://(tNonet startswithtsplittlenR(RRt bucket_nametkey_namet s3_componentstmsg((s@/opt/freeware/lib/python2.7/site-packages/boto/sqs/bigmessage.pyt_get_bucket_key<s   cCsˆ|j|jƒ\}}|r+|r+|jStjƒ}tjƒ}|j|ƒ}|j|ƒ}|j|ƒd||f|_|jS(s  :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. s s3://%s/%s( RRtuuidtuuid4tbotot connect_s3t get_buckettnew_keytset_contents_from_file(RtvalueRRts3_connt s3_buckettkey((s@/opt/freeware/lib/python2.7/site-packages/boto/sqs/bigmessage.pytencodeNs    cCsl|j|ƒ\}}|rO|rOtjƒ}|j|ƒ}|j|ƒ}|Sd|}t||ƒ‚dS(NsUnable to decode S3 URL: %s(RRRRtget_keyR(RRRRRRRR((s@/opt/freeware/lib/python2.7/site-packages/boto/sqs/bigmessage.pyt_get_s3_objectas   cCs"||_|j|ƒ}|jƒS(N(RR tget_contents_as_string(RRR((s@/opt/freeware/lib/python2.7/site-packages/boto/sqs/bigmessage.pytdecodels cCs?|jr(|j|jƒ}|jƒntt|ƒjƒdS(N(RR tdeleteRR(RR((s@/opt/freeware/lib/python2.7/site-packages/boto/sqs/bigmessage.pyR#qs  N( t__name__t __module__t__doc__R RRRR R"R#(((s@/opt/freeware/lib/python2.7/site-packages/boto/sqs/bigmessage.pyRs   (RRtboto.sqs.messageRtboto.exceptionRR(((s@/opt/freeware/lib/python2.7/site-packages/boto/sqs/bigmessage.pyts