Hi,
I am trying to use Apache Thrift for creating an API offering many
functionalities which include file uploads as well. Nothing to bother
about, it is another full-stack language independent client/server
webserice like SOAP.
It supports, int, string, bool and some other basic stuff. There is no
File datatype in the Thrift service, which I can use to send the files
attaching them directly. The max I should be using for file uploads is
the string datatype.
I have received some advice from some Thrift guys saying that we can
definitely upload some files through the thrift web services. I have to
convert the file into binary strings, assign that converted string to a
string variable and then send it via thrift to the server.
In this process, I am able to convert the file into a string by the
File.read(’<file_path>’,‘rb’){|f| f.read} OR
IO.read(’<file_path>’)
command.
I am able to send them across the Thrift service, but I have to convert
it on the server side to the actual file.
When I am doing the writing with the help of File.new
File.new(’<new_file_path>’,‘w’){|f| f << transferred_file_content}
, I am actually not getting the complete file. The size of the file is
almost equal to the actual file(infact a little more), but the file is
not complete. This is working for simple txt files, but if I want to use
this for .doc and PDF files, this is not working. I think there is
something I am missing.
Really appreciate some help on this.
Sandy