NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: astahl on February 21, 2015, 05:04:17 AM
-
Hi Bruce,
Trying the new file upload service you talked about in last week's webinar. I am getting the below errors when compiling.
PrimeParameters routine
If p_web.xml = 0 ! incoming parameters are just url encoded, either in the URL, or as post data, or as a cookie.
If p_web.IfExistsValue('username') then username = p_web.GetValue('username').
If username = ''
p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'username', 'Parameter must not be zero or blank','')
End
If p_web.IfExistsValue('password') then password = p_web.GetValue('password').
If password = ''
p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'password', 'Parameter must not be zero or blank','')
End
If p_web.IfExistsValue('jobnumber') then jobnumber = p_web.GetValue('jobnumber').
If jobnumber = ''
p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'jobnumber', 'Parameter must not be zero or blank','')
End
filename.Free()
If p_web.IfExistsValue('filename') then filename.SetValue(p_web.GetFileFromPost('filename')).
! p_web.RequestMethodType could be one of NetWebServer_GET, NetWebServer_PUT, NetWebServer_POST, NetWebServer_DELETE
Else ! incoming parameters are in an xml structure
strxml.SetValue(p_web.GetValue('xml'))
Clear(username)
username = strxml.between(p_web.Nocolon('<username>',Net:SingleUnderscore+Net:NoSpaces),p_web.Nocolon('</username>',Net:SingleUnderscore+Net:NoSpaces))
If username = ''
p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'username', 'Parameter must not be zero or blank','')
End
Clear(password)
password = strxml.between(p_web.Nocolon('<password>',Net:SingleUnderscore+Net:NoSpaces),p_web.Nocolon('</password>',Net:SingleUnderscore+Net:NoSpaces))
If password = ''
p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'password', 'Parameter must not be zero or blank','')
End
Clear(jobnumber)
jobnumber = strxml.between(p_web.Nocolon('<jobnumber>',Net:SingleUnderscore+Net:NoSpaces),p_web.Nocolon('</jobnumber>',Net:SingleUnderscore+Net:NoSpaces))
If jobnumber = ''
p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'jobnumber', 'Parameter must not be zero or blank','')
End
filename.Free()
filename.SetValue(strxml.between(p_web.Nocolon('<filename>',Net:SingleUnderscore+Net:NoSpaces),p_web.Nocolon('</filename>',Net:SingleUnderscore+Net:NoSpaces)))
filename.Base64Decode()
End
Not sure what I need to set for the filename.
Ashley
-
Hi Bruce,
It needed StringTheory declared in LocalData ,
ST Class(StringTheory)
I had StringTheory extension populated but it did not pick it up so I put it in local data and it has now compiled.
I think it should have told me it needed StringTheory for the Parameter when I selected Type as a File in the Parameters List.
Also how would one request a report as a service in pdf format to download?
Ashley
-
Hi Ashley,
thanks - I'll look into the StringTheory thing - that should be easier methinks.
>> Also how would one request a report as a service in pdf format to download?
I guess an example of that would be helpful - I'll try and put one together.
I guess this is specifically for the case where a _program_ is getting the PDF? and presumably saving it for a user somewhere?
cheers
Bruce
-
Hi Bruce,
Thanks for looking into that.
Yes, your presumption is correct. I would like to have some reports and a data export as a service. That would allow a client to request these on demand instead of us having to generate all at once, and then ftp all to the client.
How does on get the files name from the post? Is the file uploaded first and then the Service Method called?
Also I am now getting this in my file upload service documentation(see attached png) since I added String Theory to filename.
Thanks for all the help!
Ashley
[attachment deleted by admin]
-
Hi Ashley,
>> How does one get the files name from the post?
In my app I added a second field to the parameters list. ie one for the filename, one for the file itself. This gives the client program
the ability to set the name explicitly.
>> Is the file uploaded first and then the Service Method called?
yes. The file is received, and in ram when the ServiceMethod is called. At this point though it has not been saved. If you want to save it then call
ST.SaveFile(whatever)
where ST is the name of your File Parameter.
>> Also I am now getting this in my file upload service documentation(see attached png) since I added String Theory to filename.
yes, thanks, I'm looking into this.
cheers
Bruce
-
Hi Bruce,
Info much appreciated.
Thanks,
Ashley