I suspect not many have been using Aloe Express for file up loading.
For the last day+ I have been banging my head against the wall trying to get file uploading to an AE server to work consistently.
A specific file was always getting truncated… I assumed the issue was a bug in my code that created the POST multipart form content… but after going through it with a fine tooth comb (think micron teeth spacing! ;)) many times, I could find nothing wrong so started digging into the AE code…
As I said the bug did not always occur … It turns out it depended on the CONTENT of the file being uploaded.
The problematic code is in Reponse.MultiPartformHandle and cascaded from this line:
// Split the part into its header and content.
Dim PartComponents() As String = Parts(i).Split(EndOfLine.Windows + EndOfLine.Windows)
Later on in the code this line appears
// Get the part content.
Dim PartContent As String = PartComponents(1)
PartComponents(0) should always have the header data and that is OK…
But the code as written assumes that all the content is in PartComponents (1) … but that won’t be the case if the file contains
CrLfCrLf sequences, and mine did.
I modified the code in the loop used to process each for part to parse the headers from the body this way:
Dim PartContent As String = Parts(i)
Parts(i) = "" ' Free memory as quickly as possible
' Find position of the part header/content delimiter
Dim idx as integer = PartContent.InStr(EndOfLine.Windows + EndOfLine.Windows)
' If no delimiter than this part has no content for sure...
if idx = 0 then Continue
// Split the part into its header and contents.
Dim PartHeaders() As String = PartContent.LeftB(idx-1).SplitB(EndOfLine.Windows)
PartContent = PartContent.MidB(idx +4)
I made some adjustments in the code after that to be consistent with how I did the split, and everything worked as expected.
Hope this helps if anyone else runs into this!
- karen