Errors uploading large PDF's from stream
Monday, May 16, 2016 at 09:12amWe 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)
      
                                    
Reply to: Errors uploading large PDF's from stream
Monday, May 16, 2016 at 08:11pmReply to: Errors uploading large PDF's from stream
Tuesday, May 17, 2016 at 01:00pmDim 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.Reply to: Errors uploading large PDF's from stream
Wednesday, May 18, 2016 at 06:18amReply to: Errors uploading large PDF's from stream
Wednesday, May 18, 2016 at 06:23amReply to: Errors uploading large PDF's from stream
Wednesday, May 18, 2016 at 06:24amReply to: Errors uploading large PDF's from stream
Wednesday, May 18, 2016 at 06:54amReply to: Errors uploading large PDF's from stream
Wednesday, May 18, 2016 at 07:05amReply to: Errors uploading large PDF's from stream
Wednesday, May 18, 2016 at 07:38amReply to: Errors uploading large PDF's from stream
Wednesday, May 18, 2016 at 08:59am