![]() |
|
Save Post File issue - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: Save Post File issue (/thread-2670.html) |
Save Post File issue - Blanca80 - 03-14-2022 Hello everybody, I have implemented the iw.content.xml execute function like the deploy in PostDataDemo and it works fine. The problem is when i save the file that i posted for example like this 1. catch the file. (only 1 file) xFile := THttpFile(aRequest.Files[0]); 2. save the file directly on the server. xFile.SaveToFile(FTempName); That "new" posted file has added the following headers/ foot: -----------------------8da05d7825e0cb7 Content-Disposition: form-data; name="file"; filename="STR7F6F_14_03_2022_16_27_02.TXT" Content-Type: application/octet-stream . . . -----------------------8da05d7825e0cb7-- In some types of files this ends in their corruption, like excel ones. If i load this into filestream and then save it is the same. the only thing that occurs to me is to load into a streamreader object, read the lines, and discard the boundaries and the header ones. But is there an easiest way to do that? In resume how do i can avoid the boundaries and header lines in the httpfile before save? Thank you very much kind regards Blanca RE: Save Post File issue - Alexandre Machado - 03-16-2022 This doesn't look right to me. I believe you are not sending the data (the file) with proper content-type header field. It needs to be "multipart/form-data" so IW will parse the content out of that stream for you, automatically, set the file name accordingly, etc. RE: Save Post File issue - Blanca80 - 03-16-2022 (03-16-2022, 12:55 AM)Alexandre Machado Wrote: This doesn't look right to me. I believe you are not sending the data (the file) with proper content-type header field. It needs to be "multipart/form-data" so IW will parse the content out of that stream for you, automatically, set the file name accordingly, etc. Hello, The program who sends the request is an old one done in C# the code in C# is: WebClient wc = new WebClient(); byte[] responseArray = wc.UploadFile(url, "POST", fileName); Log.Text = Log.Text + "\nSubirFichero.responseArray: " + System.Text.Encoding.ASCII.GetString(responseArray); sw.WriteLine(Log.Text); wc.Dispose(); where filename is a file from client pc who sends the request to the server (url) that is a content handler in IW. I don't add any header to it. I think visual studio do that within uploadfile function. Maybe there is any incompatibility between visual studio and intraweb? Thank you Blanca RE: Save Post File issue - Blanca80 - 03-16-2022 (03-16-2022, 07:58 AM)Blanca80 Wrote:(03-16-2022, 12:55 AM)Alexandre Machado Wrote: This doesn't look right to me. I believe you are not sending the data (the file) with proper content-type header field. It needs to be "multipart/form-data" so IW will parse the content out of that stream for you, automatically, set the file name accordingly, etc. Hello Alexandre, Finally i've solved the problem changing the request in c# and adding the headers. Thank you very much for your orientation, that helped me to find the solution. kind regards! B RE: Save Post File issue - Alexandre Machado - 03-17-2022 Great! Thanks for the feedback |