Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Save Post File issue
#1
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
Reply
#2
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.
Reply
#3
Star 
(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
Reply
#4
(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, 

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

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
Reply
#5
Great! Thanks for the feedback
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)