0

What am i doing wrong? I have the autorization, I have the bucket, I have the file but i can't upload it, and it's too large to use UploadObject.

here's the part of the upload of my code

using (StreamReader streamReader = new StreamReader(filePath))
            {   Byte[] buffer = new Byte[2097153];
                var QtdeBytesFaltantes = streamReader.BaseStream.Length;
                var byteInicio = 0;
                var byteFim = 0;
                while (QtdeBytesFaltantes > 0)
                {
                    byteFim = await streamReader.BaseStream.ReadAsync(buffer, 0, buffer.Length);
                    await objectsApi.UploadChunkAsync(bucketKey,
                        Path.GetFileName(filePath),
                        (int)streamReader.BaseStream.Length,
                        "bytes " + byteInicio + "-" + byteFim + "/" + (int)streamReader.BaseStream.Length,
                        "IdUnicoDaSessao",
                        streamReader.BaseStream);

                    QtdeBytesFaltantes -= buffer.Length;
                    byteInicio = byteFim + 1;
                }

                dynamic response = await objectsApi.GetObjectAsync(bucketKey, Path.GetFileName(filePath));

                return response;

1 Answers1

0

Seems you are using the .Net Forge SDK and C#.

An example to use chunks is located here

A chunk needs to be at least 2Mb (we recommend minimum 5Mb, but 2Mb is enforced by the system). Only the last piece can be less than 2 Mb - see this article for details.

Seems your math to calculate chunk length isn't correct, when using the sample listed above, I do print the chunks range defintions, so you can compare with yours.

Hope it helps,

cyrille
  • 2,616
  • 1
  • 10
  • 18
  • Thank you cyrille your comment helped me a lot. But there's one thing that is still bothering me, i just tested the example you told me to and a file of 22mb is taking 240s to upload, that's not right (at least i don't think so) – L. Silverio Feb 16 '17 at 12:22
  • Have you tried to download it after using the download command from the same sample and compare the results? hey should be the same. let me know if not – cyrille Feb 16 '17 at 13:14
  • I use a dropbox file, that i download the file then I write it on my server then I do the upload to the forge bucket to translate it. any ideas on how to improve that? ps: It's taking roughly 1 min per 5mb chunk. – L. Silverio Feb 16 '17 at 13:18
  • Not really, excepted write to your server. You could do memory only to save time and space, but the Forge API does not let you download to bucket from a URI yet. Teh only API which can do it is the Design Automation API at this time. – cyrille Feb 16 '17 at 17:11