You are viewing limited content. For full access, please sign in.

Question

Question

SimpleExportSync in Laserfiche Cloud API

asked on August 7, 2022 Show version history

Anyone have a pointer to the proper use of the SimpleExportSync in the v2-alpha version of the Laserfiche Cloud API?

I have been able to call it and it returns another link to download but that link never seems to finish.  I believe it is related to authentication.  I suspect it is something simple but I could not figure out the magic trick to get it to work.

Thanks!

 

0 0

Replies

replied on August 8, 2022

Hi,

1. Would you please let us know the parameters of the export request?

2. Does it fail when trying to download the link directly in a browser? 

0 0
replied on August 16, 2022

I can download from the repository directly if that is what you mean.

I guess what I'm really looking or is concrete samples on how to authenticate with the v2 version of the API since it seems there was a big change in how that works between v1 and v2. 

The call I'm making is this:

ODataValueOfString sUrl = await api.SimpleExportAsync(RepoId, id, Part.Pages, Format.PDF, null, null);

  • RepoId is my repository id
  • id is the document I'm trying to download

 

I get back an sUrl value but when I attempt to download that url it just never ends.  I'm fairly certain it has to do with authentication but I cannot find any samples on the correct way to do this.

I'm using .NET if that helps with the sample but I'm not using your SDK. Just calling the API directly by using the swagger definition in Visual Studio project.

 

Thank you!

0 0
replied on August 16, 2022

Thank you for you response and information. For the second point, I meant when you call the api and get back a URl, what happens when you try to open that url in the browser? 

0 0
replied on August 23, 2022

I was able to get this to work.

snippet:

ODataValueOfString fileExport = await api.SimpleExportAsync(RepoId, id, Part.Pages, Format.PDF, null, null);

GetPDFStream(fileExport.Value, OutputFilename);  // see below for this function

OutputFilename is the destination of the downloaded file.

private void GetPDFStream(string PDFUrl, string outputFilename)
{
    WebClient webClient = new WebClient();
    using (MemoryStream ms = 
           new MemoryStream(webClient.DownloadData(PDFUrl)))
    {
        FileStream fs = new FileStream(
                 outputFilename, FileMode.Create, FileAccess.Write);
        ms.WriteTo(fs);
        fs.Close();
        ms.Close();
    }            
}

Apparently the URL returned from SimpleExportAsync isn't actually protected in any way other than generating a random string for the url.  I don't love that aspect but I have seen other companies do this too.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.