Bjones82 | Posts: 27

Errors uploading large PDF's from stream

0 votes
We keep the byte info of a PDF in our database (BLOB). If I create packages with PDF's that are 1-2 pages I have no issues, but we have a PDF that has 7 pages and when we try to create a package with the larger PDF we get this error using the byte stream this is not an issue when uploading the doc directly: {Silanis.ESL.SDK.EslServerException: Could not upload document to package. Exception: The remote server returned an error: (400) Bad Request. HTTP POST on URI https://sandbox.e-signlive.com/api/packages/304d1ae6-7a90-4daf-bda2-d5e011f360f1/documents. Optional details: {"technical":"Cannot upload document DocId. Please make sure it is not locked.","packageId":null,"messageKey":"error.validation.verifyDocument.notLocked","entity":null,"message":"Cannot upload document. Please make sure it is not locked.","code":400,"name":"Validation Error"} ---> Silanis.ESL.SDK.EslServerException: The remote server returned an error: (400) Bad Request. HTTP POST on URI https://sandbox.e-signlive.com/api/packages/304d1ae6-7a90-4daf-bda2-d5e011f360f1/documents. Optional details: {"technical":"Cannot upload document DocId. Please make sure it is not locked.","packageId":null,"messageKey":"error.validation.verifyDocument.notLocked","entity":null,"message":"Cannot upload document. Please make sure it is not locked.","code":400,"name":"Validation Error"} ---> System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest.GetResponse() at Silanis.ESL.SDK.Internal.HttpMethods.MultipartPostHttp(String apiToken, String path, Byte[] content, String boundary, AuthHeaderGenerator authHeaderGen) --- End of inner exception stack trace --- at Silanis.ESL.SDK.Internal.HttpMethods.MultipartPostHttp(String apiToken, String path, Byte[] content, String boundary, AuthHeaderGenerator authHeaderGen) at Silanis.ESL.SDK.RestClient.PostMultipartFile(String path, Byte[] fileBytes, String boundary, String json) 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.UploadDocument(String fileName, Byte[] fileContent, Document document, DocumentPackage documentPackage) at Silanis.ESL.SDK.EslClient.UploadDocument(Document document, DocumentPackage documentPackage) Here is a sample of some test code I made that reproduces the issue Dim stream As Byte() Using conn As New SqlClient.SqlConnection("Server=server;User Id=MyUser;Password=password;Database=testdb") conn.Open() Dim comm As New SqlClient.SqlCommand With comm .Connection = conn .CommandType = CommandType.Text .CommandText = "SELECT Data FROM Document WHERE DocumentId = 15" End With stream = comm.ExecuteScalar End Using Dim DocStream As New MemoryStream(Stream) Dim pack As DocumentPackage = PackageBuilder.NewPackageNamed("BillsFinalPackage") _ .DescribedAs("Bills test send") _ .WithDocument(DocumentBuilder.NewDocumentNamed("DocApplyTest") _ .WithId("DocId") _ .FromStream(DocStream, DocumentType.PDF)) _ .ExpiresOn(DateAdd(DateInterval.Day, 30, Date.Today)) _ .Build() Dim packageId2 As PackageId = Client.CreatePackage(pack)

mwilliams | Posts: 957

Reply to: Errors uploading large PDF's from stream

0 votes
How large is the file? Does there seem to be a particular size where they're getting cut off? I know you say 7 pages, but what is the MB size of these documents? Do they fail only at 7? Or do they fail at 6, 5, etc? Let me know. I'll also check around and see if anyone has seen this issue before, in the morning.

mwilliams | Posts: 957

Reply to: Errors uploading large PDF's from stream

0 votes
Hey Bill, I was able to do this without issue from MySQL with a 7 page file of yours given to me by support. Here is my code:
Dim conn As New MySqlConnection
        Dim SQL As String = "SELECT filedata, filelength FROM myfilestable"
        Dim cmd As New MySqlCommand
        Dim myData As MySqlDataReader
        Dim myFileData() As Byte
        Dim myfilestream As MemoryStream
        Dim FileSize As UInt32
        Dim api_key As String
        Dim api_url As String
        Dim eslClient As EslClient

        conn.ConnectionString = "server=127.0.0.1;" _
                                 & "uid=YOUR_USERNAME;" _
                                 & "pwd=YOUR_PASSWORD;" _
                                 & "database=YOUR_DB_NAME;"
        Try
            conn.Open()

            cmd.Connection = conn
            cmd.CommandText = SQL

            myData = cmd.ExecuteReader

            If Not myData.HasRows Then Throw New Exception("There is no data to read")
            myData.Read()

            FileSize = myData.GetUInt32(myData.GetOrdinal("filelength"))
            myFileData = New Byte(FileSize) {}
            myData.GetBytes(myData.GetOrdinal("filedata"), 0, myFileData, 0, FileSize)
            myfilestream = New MemoryStream(myFileData)

        Catch ex As Exception
            Throw New Exception("There was an error: " & ex.Message)
        End Try

        api_key = "YOUR_KEY"
        api_url = "https://sandbox.e-signlive.com/api"

        eslClient = New EslClient(api_key, api_url)

        Dim pack As DocumentPackage = PackageBuilder.NewPackageNamed("BillsFinalPackage") _
        .DescribedAs("Bills test send") _
        .WithDocument(DocumentBuilder.NewDocumentNamed("DocApplyTest") _
        .WithId("DocId") _
        .FromStream(myfilestream, DocumentType.PDF)) _
        .ExpiresOn(DateAdd(DateInterval.Day, 30, Date.Today)) _
        .Build()
        Dim packageId2 As PackageId = eslClient.CreatePackage(pack)
Hope this helps. Let me know.

Bjones82 | Posts: 27

Reply to: Errors uploading large PDF's from stream

0 votes
Ok I tried everything again and it still failed. I spoke with my QA and they informed me that they gave me the wrong document when I asked what this upload contained. I have the correct document now. Is there an email address I can send the document too so you guys can check it out because I confirmed this document will not upload via memory stream option and filepath option

mwilliams | Posts: 957

Reply to: Errors uploading large PDF's from stream

0 votes
You can mail it to [email protected]. That will come directly to me.

mwilliams | Posts: 957

Reply to: Errors uploading large PDF's from stream

0 votes
You could also send it to [email protected] and they could get it to me. :)

mwilliams | Posts: 957

Reply to: Errors uploading large PDF's from stream

0 votes
The file you just sent is encrypted and secured by a password. If I were to copy the document to make changes to it, I couldn't as it would be locked. This is probably the problem that eSignLive is having with it. You can see the security level in the attached image. If I try to change this to no security, it asks me for a password.

Attachments
Bjones82 | Posts: 27

Reply to: Errors uploading large PDF's from stream

0 votes
Thanks for looking at that. I will bring this back to QA for things to look for when creating packages.

mwilliams | Posts: 957

Reply to: Errors uploading large PDF's from stream

0 votes
Not a problem. Let us know whenever you have questions! :)

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