Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
tim
10 years agoExplorer | Level 4
Download folder as ZIP in api v2?
One of my apps that i'm trying to migrate from API v1 to v2 uses the v1 functionality where you can download https://content.dropboxapi.com/1/files/auto/path/to/folder, and dropbox sends you a ZIP fi...
- 10 years ago
Hi Tim, API v2 doesn't offer zip folder downloads, but I'll pass this along as a feature request.
(Also, I'm not sure exactly what functionality you're referring to on v1, as there's no documented/supported zip folder download functionality on the /files endpoint you're referring to. Perhaps you're referring to the ability to download a zip from a shared link for a folder using the dl or raw URL parameters? That's unrelated to API version.)
Greg-DB
Dropbox Community Moderator
8 years agoThe Dropbox API v2 now offers the ability to download folders as zips:
https://www.dropbox.com/developers/documentation/http/documentation#files-download_zip
If you're using an official SDK, there will also be a corresponding method for this endpoint.
https://www.dropbox.com/developers/documentation/http/documentation#files-download_zip
If you're using an official SDK, there will also be a corresponding method for this endpoint.
frphotos
8 years agoExplorer | Level 4
Okay. I am sharing this code for people who needs to download dropbox folder as zip in C#. I can't find a solution in the web and I have to piece up my own code. Hope it helps.
private async Task Download(string foldername)
{
string token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var dbx = new DropboxClient(token);
using (var response = await dbx.Files.DownloadZipAsync("/" + foldername))
{
Stream ms = await response.GetContentAsStreamAsync();
Int16 bufferSize = 1024;
byte[] buffer = new byte[bufferSize + 1];
Response.Clear();
Response.ContentType = "application/x-zip-compressed";
Response.AddHeader("content-disposition", "attachment; filename=myfolder.zip");
Response.BufferOutput = false;
int count = ms.Read(buffer, 0, bufferSize);
while (count > 0)
{
Response.OutputStream.Write(buffer, 0, count);
count = ms.Read(buffer, 0, bufferSize);
}
}
}
//To call it, place the download function in a page_load of a aspx (example: download.aspx)
//Link example: http://domainname/download.aspx?folder=abc123
//This link will directly download the folder as a zip file.
protected void Page_Load(object sender, EventArgs e)
{
string dropbox_folder = Request.QueryString["folder"];
if (dropbox_id == null)
Response.Redirect("http://google.com");
try
{
var DownloadTask = Task.Run(async () =>
{
await Download(dropbox_folder);
});
DownloadTask.Wait();
}
catch (Exception ex)
{
Response.Redirect("http://google.com");
}
}
About Dropbox API Support & Feedback
Find help with the Dropbox API from 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!