Chris-Svprx | Posts: 9

document content is null?

0 votes

Trying to save signed docs on our server.  Looping through the doc collection, Content is null with code bellow:

  //retrieve signed package from one span
            var pkg = oss.GetPackage(req.PackageId);

            foreach (var doc in pkg.Documents)
            {
                //assume docName was set up according to a good pattern
                var path = "documents/" + doc.Name + ".pdf";
                File.WriteAllBytes(path, doc.Content);
            }

Code below works, but seems like a waste to call OneSpan for each doc in the package.

 foreach (var doc in pkg.Documents)
            {
                //assume docName was set up according to a good pattern
                var path = "documents/" + doc.Name + ".pdf";
                byte[] pdfDocumentBytes = oss.Client.DownloadDocument(pkg.Id, doc.Id);
                File.WriteAllBytes(path, pdfDocumentBytes);
            }

Why does doc object have a Content prop if it is empty?


Duo_Liang | Posts: 3776

Reply to: document content is null?

0 votes

Hi Chris,

 

You need to invoke extra calls to download document content, that's because the file binary is not coming together with the .GetPackage() response. To further reduce the number of outbound API calls, you can download all the signed documents in a zip file, and extract it in memory before saving to local separately.

byte[] zipContent = eslClient.DownloadZippedDocuments(packageId);

 

Duo


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off