иметь больше контроля над вы можете разделить ваши файлы на более мелкие блоки, загрузить один блоки, показывают прогресс на основе загруженных блоков и фиксируют загрузку, как только все блоки будут успешно перенесены. Вы можете одновременно загружать несколько блоков одновременно, приостанавливать/возобновлять загрузку в течение 7 дней или повторять попытки загрузки блоков.
Это, с одной стороны, больше кодировки, но с другой стороны больше контроля.
В качестве точки входа, здесь приведен пример кода в C#, так как я не знаком с Java для Android:
CloudBlockBlob blob = cloudBlobContainer.GetBlockBlobReference(Path.GetFileName(fileName));
int blockSize = 256 * 1024; //256 kb
using (FileStream fileStream =
new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
long fileSize = fileStream.Length;
//block count is the number of blocks + 1 for the last one
int blockCount = (int)((float)fileSize/(float)blockSize) + 1;
//List of block ids; the blocks will be committed in the order of this list
List<string> blockIDs = new List<string>();
//starting block number - 1
int blockNumber = 0;
try
{
int bytesRead = 0; //number of bytes read so far
long bytesLeft = fileSize; //number of bytes left to read and upload
//do until all of the bytes are uploaded
while (bytesLeft > 0)
{
blockNumber++;
int bytesToRead;
if (bytesLeft >= blockSize)
{
//more than one block left, so put up another whole block
bytesToRead = blockSize;
}
else
{
//less than one block left, read the rest of it
bytesToRead = (int)bytesLeft;
}
//create a blockID from the block number, add it to the block ID list
//the block ID is a base64 string
string blockId =
Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(string.Format("BlockId{0}",
blockNumber.ToString("0000000"))));
blockIDs.Add(blockId);
//set up new buffer with the right size, and read that many bytes into it
byte[] bytes = new byte[bytesToRead];
fileStream.Read(bytes, 0, bytesToRead);
//calculate the MD5 hash of the byte array
string blockHash = GetMD5HashFromStream(bytes);
//upload the block, provide the hash so Azure can verify it
blob.PutBlock(blockId, new MemoryStream(bytes), blockHash);
//increment/decrement counters
bytesRead += bytesToRead;
bytesLeft -= bytesToRead;
}
//commit the blocks
blob.PutBlockList(blockIDs);
}
catch (Exception ex)
{
System.Diagnostics.Debug.Print("Exception thrown = {0}", ex);
}
}
Что касается # 1 см это: http://stackoverflow.com/questions/21175293/как к трассе-прогресс-оф-асинхронном-файл-загрузки-на-лазурного-хранилище. Для # 2 и # 3, пожалуйста, поделитесь больше кода. Как вы выполняете обработку ошибок в своем коде? –