This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I need to upload a image file(.jpg) from an application written in C++. Basically this c++ application passes the fileName and encoded fileData as parameters to my servlet. I will fetch these parameters from my servlet, decode the fileData and write it to a file. Currently, i have o'reilly's package downloaded to decode this encoded parameter. The question is, is there a limit on the length of the parameter string? Also the encoded string might contain some special carriage return chars, i guess that would be a problem, if i use this method. Also if there is a better way to do this, please let me know. Thanks. Appreciate your input.
From the sounds of it your are going to do something similar to Base64 Encodeing the binary data into (safe) character data then add it to a URL? Firstly, I recommend you don't do this since the 'safe limit' for the length of URLs is 255 characters (see RFC2616 section 3.2.1) I still tend to use URLs longer than this, but it depends on support by browsers, servers, proxies and any other application between you and the destination. The other problem is that Base64 Encoding adds approximately 30% to the length of binary data, and it also uses the 'equals' character. THis means you will have to escape special characters too. You are far better having a look at 'multipart/form-data', which is the way that HTTP uploads files. You can then generate this HTTP header and send it to the server with the added advantage that you don't need to worry about 'special characters' or data length. A search in this forum for 'multipart/form-data' should give much more data. (And I think there was a conversation a while back in the IO and Streams forum on how to build this header from scratch) Dave [ May 29, 2002: Message edited by: David O'Meara ]
Joined: Jun 26, 2001
Thanks for your input. Could you please give me an outline as to how i can write the http header stuff from the scratch. Appreciate u'r help, Thanks.