devries48 | Posts: 1

Crash on document name when sending package

0 votes
Hi, I receive an error when the document name ends with "pdf". For example "Testpdf.pdf". My workaround is to add another character to the document name ("Testpdfx.pdf"). Perhaps something to attend to in a future release. regards, Ronald The error: Silanis.ESL.SDK.EslException: Could not upload document to package. Exception: Index and count must refer to a location within the string. Parameter name: count ---> System.ArgumentOutOfRangeException: Index and count must refer to a location within the string. Parameter name: count at System.String.Remove(Int32 startIndex, Int32 count) at Silanis.ESL.SDK.Internal.MimeTypeUtil.GetMIMEType(String fileName) at Silanis.ESL.SDK.Services.PackageService.CreateMultipartContent(String fileName, Byte[] fileBytes, Byte[] payloadBytes, String boundary) at Silanis.ESL.SDK.Services.PackageService.UploadDocument(DocumentPackage package, String fileName, Byte[] fileBytes, Document document) --- End of inner exception stack trace --- at Silanis.ESL.SDK.Services.PackageService.UploadDocument(DocumentPackage package, String fileName, Byte[] fileBytes, Document document) at Silanis.ESL.SDK.EslClient.CreatePackage(DocumentPackage package) at Silanis.ESL.SDK.EslClient.CreateAndSendPackage(DocumentPackage package) My code (shortend):
var doc = DocumentBuilder.NewDocumentNamed(document.Name).FromStream(fs, docType).WithId(request.DocumentId.ToString());
...
package.WithDocument(doc);
var packageId = eslClient.CreateAndSendPackage(package.Build()); // -- The error occurres here

Duo_Liang | Posts: 3776

Reply to: Crash on document name when sending package

0 votes
Hi devries, Welcome to OneSpan Sign and thanks so much for your sharing and contribution to our community! Just want to have few technical discussion with you on this topic: I believe the error throws from this function which is used to extract mimetype from fileName:
var fileName = "testpdf.pdf";
var mimeType = Silanis.ESL.SDK.Internal.MimeTypeUtil.GetMIMEType(fileName);
But I can't receive the same error unless I put no extension(.pdf/.docx/.rtf/.odt), no matters whether it's ending with "pdf". And in your case, you are using .FromStream(fs, docType) which means there must be a docType (I derive this from the Java SDK, following is the source code)
    public DocumentBuilder fromStream( InputStream input, DocumentType type ) {
        this.documentSource = new StreamDocumentSource( input );
        this.fileName = type.normalizeName( name );
        return this;
    }
So can you share me more about how to reproduce this error? And thanks again for your posting. :) Duo

dryder | Posts: 1

Reply to: Crash on document name when sending package

0 votes

Was this ever resolved? I'm getting the same error. The document will upload by calling package.WithDocument(DocumentBuilder.NewDocumentNamed(doc.name)
                                                  .FromStream(fs, Silanis.ESL.SDK.DocumentType.PDF));

 

The exception happens when calling CreatePackage(package)


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