Free Support Forum - aspose.cloud

Download PDF from cloud storage in Go with Aspose.Words Cloud API

Hi,

After DOCX to PDF conversion, I see the pdf file in the “My Files” storage section. I tried using the pdf api DownloadFile but I got a 401 error. Could you help me take a look?


This Topic is created by tilal.ahmad using Email to Topic tool.

@tnhuynh

Thanks for your inquiry. Please note if you are using Aspose.Words Cloud SDK for Go for file conversion then you can use it for cloud storage related operations as well.

Please use following code of Aspose.Words Cloud API to download PDF document from storage instead of Aspose.PDF Cloud API.

//download file

options := map[string]interface{}{}

out, _ := os.Create("test.pdf")

output, err := api.DownloadFile(ctx, "test_doc.pdf", options)

defer output.Body.Close()

io.Copy(out, output.Body)
   
if err != nil {

      fmt.Println(err)

 }

@tilal.ahmad
Thank you for letting me know!
Is there one API call I can make to convert to PDF and get the PDF file back in the response instead of making 2 separate calls using ConvertDocument() and DownloadFile()? This will also help with eliminating the need to clean up pdf files in the storage.

@tnhuynh

Thanks for your feedback. Please note when you do not set output file path in API call, it will return output file in response body. So you do not need to download output file using separate API call.

A post was split to a new topic: Get Word Document Statistics with a single Call