[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);
}
}