From: Robert Klemme Date: 2013-05-28T01:58:02+09:00 Subject: Re: Converting an xml file to byte array in ruby --047d7bdc0e1e2b5d3704ddb60d6e Content-Type: text/plain; charset=ISO-8859-1 On Mon, May 27, 2013 at 6:50 PM, Khudadad Kazi wrote: > OK. to be more specific, here is my method: > def > > add_file_to_project(ticket,pid,fileName,fileData,srcId,targetIds,metadata=nil) > require 'savon' > received_path=@path > client = Savon.client do > wsdl received_path > end > message = {'Ticket' => ticket, 'ProjectID' => pid,'Filename' => > fileName, 'FileData'=> fileData,'SourceLanguageID' => srcId, > 'TargetLanguageIDs' => targetIds, 'Metadata' => nil, > 'IsReferenceMaterial' => false, 'WebServiceType' => 'Publisher'} > response = client.call(:add_file_to_project, :message => message) > addFileToProjectResult = > response.body[:add_file_to_project_response][:add_file_to_project_result] > return addFileToProjectResult > end > > where in fileData should be a base64Binary (to which i referred as a > "byte array"). > Well, but then it's a string, isn't it? Or what type is fileData? (Btw. in Ruby we usually use "file_data"). I just need to send a file in that fileData parameter. Please show how > to achieve that when I do not put restrictions on any kind of files. If it is a String already, just leave it as is. If not, use Base64.encode64 to make it a String. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ --047d7bdc0e1e2b5d3704ddb60d6e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Mon, May 27, 2013 at 6:50 PM, Khudadad Kazi &l= t;lists@ruby-foru= m.com> wrote:
OK. to be more specific, here is my method:
def
add_file_to_project(ticket,pid,fileName,fileData,srcId,targetIds,metadata= =3Dnil)
=A0 =A0 require 'savon'
=A0 =A0 received_path=3D@path
=A0 =A0 client =3D Savon.client do
=A0 =A0 wsdl received_path
=A0 =A0 end
=A0 =A0 message =3D {'Ticket' =3D> ticket, 'ProjectID' = =3D> pid,'Filename' =3D>
fileName, 'FileData'=3D> fileData,'SourceLanguageID' =3D= > srcId,
'TargetLanguageIDs' =3D> targetIds, 'Metadata' =3D> n= il,
'IsReferenceMaterial' =3D> false, 'WebServiceType' =3D&g= t; 'Publisher'}
=A0 =A0 response =3D client.call(:add_file_to_project, :message =3D> mes= sage)
=A0 =A0 addFileToProjectResult =3D
response.body[:add_file_to_project_response][:add_file_to_project_result] =A0 =A0 return addFileToProjectResult
=A0 end

where in fileData should be a base64Binary (to which i referred as a
"byte array").
=A0
Well, but= then it's a string, isn't it? =A0Or what type is fileData? =A0(Btw= . in Ruby we usually use "file_data").

=
I just need to send a file in that fileData parameter. Please show how
to achieve that when I do not put restrictions on any kind of files.

If it is a String already, just leave it as is. =A0If not, use=A0Bas= e64.encode64 to make it a String.

Kind = regards

robert


--
remember.= guy do |as, often| as.you_can - without end
http://blog.rubybestpractice= s.com/
--047d7bdc0e1e2b5d3704ddb60d6e--