6
votes

I'm trying to create a Page Blob, because I would need random access in the future, although I can upload the file, when I download it the size is different.

I get "file.docx" uploaded, and then downloaded as "file2.docx". The downloaded one is a little bigger, actually its size is rounded to page blob page size, 512 :) In this particular case, Microsoft Word gives me a warning saying the file is corrupt, but I can still open it and the content is what I was expecting.

I got the code example from here: Using Windows Azure Page Blobs and How to Efficiently Upload and Download Page Blobs. I've checked out the code to upload it and the documentation, and apparently your page upload must start on a 512 byte boundary (startingOffset % 512 == 0), and end on a 512 boundary - 1. Then what does happen when I need to upload a file that is not aligned to 512?

For example, if I have a file with 550bytes and I upload it and download it I'll get a file with 1024 bytes, right? What should I do? keep the original file size in the metadata or there is a way to do it right?(or example).

Thanks in advance.

2
From what I have read about Page blobs, I think the random access feature is more suitable for a drive like scenario where multiple users are writing different files in the same page blob.Gaurav Mantri
humm I see, but it is still a problem if you upload a file, and you cannot upload a 550 bytes. You have to keep the original file size somewhere or be able to read till everything 0.vtortola
You may want to look into getting occupied page ranges (msdn.microsoft.com/en-us/library/ee691973.aspx), but even with that you will have to resort to read till everything is 0 bytes. May I ask the use case where you want to use this word document (or a file) as page blob instead of a block blob? Do you envision multiple users editing same document or file at the same time?Gaurav Mantri
And how do you know that those bytes to 0 are not actual information? That is what blow my mind. Use case? Sure: freesoft.org/CIE/RFC/1123/64.htm :)vtortola
Hi, I am facing the same problem, different file sizes issue while creating a blob (image). The size of the image uploaded is different from the size of same image downloaded. So I am not able to decode the image using BitmapFactory. Any ideas?Omar Rehman

2 Answers

3
votes

Yes, you should "keep the original file size in the metadata". Or consider using block blobs.

0
votes

When you ask about Random Access - are you referring to a random access within the file or random access of multiple blobs? Your descriptions imply the latter (lots of file transfers) - i.e. small files randomly accessed, in which case a block blob will do what you need.

Do you have a use case for random seeking within the file? There are scenarios for that, but typically the file is much larger than 512bytes.