Discuss Dropbox Developer & API
Hi,
I encountered the problem "Error while copying content to a stream" when executing the above code. Is there any way to fix it?
@Rephoto, What are you doing? Batch is used when you want to upload multiple files at once, not to split one file upload and do pieces upload simultaneous!!! Use concurrent upload session to do that.
Oh sorry,
I will investigate further :((
@ЗдравкоHi, I tried again with the code below to upload small files (e.g. 10, 20MB). But the result just failed. :))
@Rephoto wrote:@ЗдравкоHi, I tried again with the code below to upload small files (e.g. 10, 20MB). But the result just failed. :))
...
Hm..
Probably I miss something, but where in your code you did upload files actually? 🧐 I cannot figure out where is this place/codeline. Please point out where you pass your files content to. Also don't forget that you should close every single session before finishing - so to be ready for finish! ![]()
Add: When you have some error, don't forget to post the actual error/unexpected result content too. There is valuable information describing the error.
@Здравко
Oh, So I'm missing the file upload part. But I don't know which one to use?
@Rephoto wrote:@Здравко
Oh, So I'm missing the file upload part. But I don't know which one to use?
In general, you should use UploadSessionAppendV2Async method to upload stream' data. In such case you can combine the batch with big files upload either sequential or concurrent. When you know that only small files are going to upload, using single call of UploadSessionStartAsync to prepare a session (together with data upload and close) may be more suitable (instead of using UploadSessionStartBatchAsync - neither data can be uploaded nor closing it).
Let's hope this clarifies matter.
@Здравко, Thank ![]()
Can I do it like this? But it gives me an exception ""Error while copying content to a stream." arrival
@Rephoto, Why are you trying to upload the same stream twice?
Previously you skipped upload at all, now just opposite! ![]()
Something else: Why you skipped finishing the all sessions in batch? In such a way, there is no optimization! Even more - you can do the same with a single call. ![]()
Why are you trying to upload the same stream twice?
Previously you skipped upload at all, now just opposite!
...
@Здравко
So after I run the UploadSessionStartAsync command, how do I finish uploading to dropbox?
Thanks
If you want to just upload a single small file and that's all, using UploadAsync is the bast. In such a way you create session, upload and close the content and finish the upload - all in this single call. Here is no any optimization. In your last code snippet you make it rather slower - 2 calls instead of one.
If you want to make multiple files upload at once and optimize the process of finish, you can use UploadSessionFinishBatchAsync as you have it done already (or rather tried to use).
That's it. Clarify to yourself what actually you want to do.
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!