Skip to main content
Question

While downloading the zip archive, the .zip extension is not present in the folder.

  • May 23, 2025
  • 2 replies
  • 38 views

Forum|alt.badge.img
 
When trying to download a zip archive from a query parameter in url with box id, I receive the downloaded file successfully. However, it's missing the ".zip" extension in its name. For example, if the zip archive is named "downloadzip", the downloaded file should ideally be named "downloadzip.zip", but it isn't. Am I missing something? According to this article (https://developer.box.com/reference/post-zip-downloads/), it explicitly states that ".zip" is added from the Box API.

public async Task<MemoryStream> GetStreamForZip(string csvFileIds)
        {
            var fileIds = csvFileIds.Split(',');            
            var request = new BoxZipRequest
            {
                Name = "downloadzip",
                Items = fileIds.Select(fileId => new BoxZipRequestItem
                {
                    Id = fileId.Trim(),
                    Type = BoxZipItemType.file
                }).ToList()
            };            using (MemoryStream ms = new MemoryStream())
            {
                await BoxClient.FilesManager.DownloadZip(request, ms);
                ms.Position = 0;
                return ms;
            }
        }
[FunctionName("downloadzip")]
public static async Task<IActionResult> DownloadZip([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log)
{
    try
    {
        string id = req.Query["id"];
        if (string.IsNullOrEmpty(id))
        {
            return new BadRequestObjectResult("Document id is not passed. Pass id as request param.");
        }        var stream = await _boxIntegrationService.GetStreamForZip(id);        if (stream == null)
        {
            return new BadRequestObjectResult("The file is not found");
        }        var bytes = stream.ToArray();        
return new FileContentResult(bytes, "application/octet-stream");
    }
    catch (Exception ex)
    {
        return new BadRequestObjectResult(ex.Message);
    }
}

2 replies

Forum|alt.badge.img

Hi Samir, 

Welcome to Box Community and glad to assist!

I have created a ticket and a member from Product Support will get in touch, please keep an eye out. 

Thanks for posting!


Forum|alt.badge.img

Hi there,

Thanks for letting me know. It's been a bit since I created the ticket. Is there anything else I should do to speed things up? Your help would be appreciated.

Hope to hear from you soon.

Regards,