We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
giahh
12 months agoNew member | Level 1
Problem with HttpClient
var uri = new Uri("https://www.dropbox.com/scl/fi/l2ltdldscgwr9ho1izx57/TestUpdate-pass.zip?rlkey=cn5adnh45sc3793j60gunn3x8&st=u8atpaop&dl=1"); var httpClientHandler = new HttpClientHandler { ...
DB-Des
Dropbox Community Moderator
12 months agoHi giahh,
I'll be happy to help with any issues you're having with Dropbox, but I'll need some more information:
- Could you confirm if you are seeing errors when the file is downloaded by accessing the link directly?
- Could you clarify how the file was uploaded to Dropbox? E.g., Dropbox API, desktop client, mobile client, or web.
- Is the error only with this specific file? Or is it happening with any files you are attempting to download from Dropbox?
I was able to download the file in question, but was unable to open it due to it being password-protected.
giahh
12 months agoNew member | Level 1
I used this code:
namespace Test_Dropbox
{
internal class Program
{
static void Main(string[] args)
{
var uri = new Uri("https://www.dropbox.com/scl/fi/4isq7l500diw6kjjd7hkq/ZipExtractor.zip?rlkey=fsoxq9o89zdqb8mr4ug8ml1uo&st=g7gpau7c&dl=1");
var httpClientHandler = new HttpClientHandler
{
AllowAutoRedirect = true,
};
var httpClient = new HttpClient(httpClientHandler);
httpClient.Timeout = TimeSpan.FromSeconds(60);
// Accept binary data
httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/octet-stream"));
HttpResponseMessage response = httpClient.GetAsync(uri).Result;
if (response.IsSuccessStatusCode)
{
byte[] zipFileData = response.Content.ReadAsByteArrayAsync().Result;
// Save the zip file to disk
File.WriteAllBytes("output.zip", zipFileData);
}
else
{
Console.WriteLine("{0}: {1} ({2})", uri, (int)response.StatusCode, response.ReasonPhrase);
}
Console.ReadKey();
Environment.Exit(0);
}
}
}it use HttpClient to Download a zip file without password from the link above and always got this error:
The zipped file seem corrupted. How could I fix the code to work properly with dropbox?
About Discuss Dropbox Developer & API
Make connections with other developers
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
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!