简体   繁体   中英

What is the maximum length of base64 encoded string that can be added to Azure queue?

I need to send compressed Base64 data over an Azure queue, which has a limitation of 64K.
My code compresses the data and then encodes it as a Base64 string.
I verify the compressed and encoded string does not exceed 64000 bytes (see encodedLen below), however, my code crashed when I tried to add a message of ~57,000 bytes .

var byteString = Encoding.UTF8.GetBytes(articleDataToSend);  
var compressed = QuickLZ.compress(byteString, 1);  
var encoded = Convert.ToBase64String(compressed);  

var encodedLen = Encoding.UTF8.GetByteCount(encoded);  
if(encodedLen < 64000)
{
    QueueMessage(_nlpInputQueue, encoded);
}

I'm using Visual Studio 2012 and .Net 4.5.
What am I missing here?

Maximum message size is 48k when using Base64 encoding http://msdn.microsoft.com/en-us/library/windowsazure/hh767287.aspx

Use Azure Service Bus Queues and you can get up to 256k

I believe you're ending up with a double-encoded string. The storage client library has historically base64-encoded everything put on a queue, so it's base64-encoding your base64-encoded string. My guess is that if you did QueueMessage(_nlpInputQueue, compressed) instead, this would work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM