DataSnap/REST - Upload image from client to server. [Edit]


I am having problem to trying send a file or JSON class for the server.

The return of the server is "message content is not a valid json value".
I use Delphi XE5. 
Also, I'm using the RESTClient and RESTRequest components for the connection.

Below is my routine client and server.


procedure SendExame(file_path: String);
  jsonObj: TJSONObject;
  mStream: TMemoryStream;
  aParam: TRESTRequestParameter;
  jsonObj := TJSONObject.Create;
    mStream := TMemoryStream.Create;
      mStream.Position := 0;
      jsonObj.AddPair('file', IdEncoderMIME.EncodeStream(mStream));

    aParam             := RESTRequest1.Params.AddItem;
    aParam.Value       := jsonObj.ToString;
    aParam.ContentType := ctAPPLICATION_JSON;

  RESTRequest1.method   := rmPost;
  RESTRequest1.Resource := 'UploadImage';

procedure TdtmServerMethods.updateUploadImage(jsonResult: TJSONObject);
  mStream: TMemoryStream;
  mStream := TMemoryStream.Create;
    TIdDecoderMIME.DecodeStream((jsonResult.Get('file').JsonValue as TJSONString).Value, mStream);
    mStream.Position := 0;
6/8/2015 7:21:13 PM
embarcadero.delphi.webservices 976 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 19


Similar Artilces:

ANN: DataSnap-like Client-Server JSON RESTful Services in Delphi 7-2010 [Edit]
How to implement a very useful service... say... adding two numbers? In our framework, you code Server-Side: {code} function TSQLRestServerTest.Sum(aRecord: TSQLRecord; aParameters: PUTF8Char; const aSentData: RawUTF8; var aResp, aHead: RawUTF8): Integer; var a,b: Extended; begin if not UrlDecodeNeedParameters(aParameters,'A,B') then begin result := 404; // invalid Request exit; end; while aParameters<>nil do begin UrlDecodeExtended(aParameters,'A=',a); UrlDecodeExtended(aParameters,'B=',b,@aParameters); end; aRes...

Datasnap Rest client and no datasnap server
Hi, it's possible to use a delphi datasnap rest client to consume a rest web services written in other lenguages (like java or php) or i have to use an idhttp (or other) component? Thanks. Bye Pasquale Di Giovanni wrote: > > it's possible to use a delphi datasnap rest client to consume a rest > web services written in other lenguages (like java or php) or i have > to use an idhttp (or other) component? You could in theory, but it may be more trouble than its worth. You'd probably have to have control of the REST server so you can implement all the...

Send Image Data from Android client to Datasnap Rest Server
I have an Android app that communicates to a Datasnap Rest Server for data exchange. The client collects data, including images and needs to store them on a SQL database on the server machine. I can send the related data no problem. My problem is working out how to send image data from the Android client to the server. I've looked at the various sample apps, but can't find anything that looks like what I need. Thanks ...

Upgrading Delphi 7 Datasnap to XE: client fails to connect to server [Edit]
Hi, I'm currently working on upgrading a codebase from Delphi 7 to XE, and am currently just trying to get an older school Datasnap application working under XE. For reference: I'm developing/testing on Windows 7 64bit and currently using Delphi XE. The client application connects to the app server via a socket connection currently, and thus uses Borland Socket server, which includes using a registered "Interceptor" which does data compression/decompression. Now the problem: Currently I'm running into a problem trying to get the client to actually talk to t...

How to know which client using the server methord in Datasnap Server? [Edit]
Hi, There are some clients which has connected the datasnap server. I have recorded their ChannelInfo.Id when these clients connect the server in Onconnect Event of Datasnap Server. Now if a client is preparing to use the Server Methord, how can I get this client's thread id or ChannelInfo.Id? I want to do this: 1.So I can record the time of this client invoked the server methord in Datasnap Server. 2.So I can disconnect this client's connection. Best regards, Sunstone Edited by: sun stone on Feb 7, 2010 10:17 PM I want this to store session info in a server having...

Connect Old Datasnap Clients with new datasnap Server ? [Edit]
Is it possible to connect a XE5 datasnap server with Borland C++ 6 Datasnap clients ? I want to know this before starting ... Edited by: Bart vd Voort vd Kleij on Jan 9, 2014 11:49 PM Edited by: Bart vd Voort vd Kleij on Jan 9, 2014 11:51 PM ...

Indy 10
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_39eb5.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" The udp client component would be used in the datasnap server. The udp server component would be used in the datasnap client. --JivePart=_39eb5.zeB8CwDOH5aMJzMl Content-Type: application/x-zip-compressed; name="" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="" UEs...

Delphi 2009 Datasnap server and client
Hello, I am trying develop Datasnap server and client. I have a type TStringArray = array of string;. I used this type in one of server method. When I am trying to Generate Datasnap Client classes it says 'Remote error:Unknow data type: TStringArray'. How can I register this data type? -- Best Regards Md. Shariful Alam Khan Hello, Isn't there anyone to answer my question? Also I am getting same error if I use TStrings or TWideStringArray. Best Regards Md. Shariful Alam Khan "Md. Shariful Alam Khan" <> wrote in messag...

Datasnap Server Getting Client List [Edit]
Hi, I have a project that uses Datasnap. I need list of all clients that still connected at a moment. Is there any way to get connection list ? I need client's IP, Connected User, Pass etc. My Clients connects via HTTP with authentication. Edited by: Umut Kose on May 10, 2010 6:25 AM ...

Reading a TDataset from a REST server in a Delphi Client
Hi, I wrote a REST Server in XE2 - that generally works fine - and I am able to use it from a Javascript client. We also wanted to use it in a Delphi client - and I have never written code with a Delphi client that accepts a dataset from a REST server. Basically, when I call my proxy (my Delphi code is in Delphi XE, where our client application is) - I get an error message, EDatabaseError 'Missing query, table name or procedure name' Any ideas what this is all about? I tried to replace the TDataset with a TClientDataset and the problem is the same. Any ideas where to con...

DataSnap REST Server/Client LifeCycle Session does not work
Hello, in this post the LifeCycle management is described. If I test this with a DataSnap REST Server and Client the LifeCycle "session" will always create/free my DSServerClass (and generate an other GUID). Is this is a bug or a limitation of the REST architecture? (Delphi XE3) Regards Mathias Pannier Am 13.06.2014 14:02, schrieb Mathias Pannier: > in this post the LifeCycle > management is described. If I test this with a DataSnap REST Server and > Client the LifeCycle &quo...

Blob Field through DataSnap Client/Server Delphi 2009
I can't pass Blob Field through DataSnap Client/Server Delphi 2009, when I try to Open the TSqlServerMethod this says Remote Error: unexpected metadata type, but, that only when the Table or Query have Blob fields. > {quote:title=ALEXANDER DAVID CRUZ MARQUEZ wrote:}{quote} > I can't pass Blob Field through DataSnap Client/Server Delphi 2009, when I try to Open the TSqlServerMethod this says Remote Error: unexpected metadata type, but, that only when the Table or Query have Blob fields. Hi. I have exactly the same problem. Seems it's not a just an error but it's a D...

Delphi xe datasnap rest server and serverside scripting
Hi all, I'm trying to use serverside scripting using the standard datasnap rest server produced automatically by Delphi but I can't figure out how to do that. Here is what I do: I create a new DataSnap Rest Application (standalone vcl app.) with all the standard choices selected. After that I want to change the ReverseString.html code so that it writes (for example) "hello word" To do that I Insert inside the html file the following script: <%= hello word %> I also set the scriptengine field of the pageproducer of the html page to the Jscript value (so that it...

IP address of clients, connected to DataSnap server [Edit]
Hello. Please help with answers: Is it possible to obtain list of clients currently connected to the DataSnap server, including IP adresses? What class i need to use for it? Edited by: Sergey Ryasnyanskiy on Jun 19, 2011 9:53 PM There is no default way to accomplish this task without some programming on your part. If you find that you can obtain the correct IP from the OnConnect event (in XE you may find the IP returned is the Server's IP) then you can store that IP in the session (Session := TDSSessionManager.GetThreadSession;) using the get/put data functions. You can later g...

REST Datasnap Server seperate Callback to multiple clients
I have a REST server that send a callback messages to the clients. Each channel get named with an int value. Channel1 -> Client1 Channel2 -> Client2 It is initiated by a common procedure an being broadcast over the SDServer, but if I inciate this call form two clients at once, just one of them gets updated and the latter have to wait for the prior to complete. Is there a way around this? ...

why delphi xe4 does not have a demo for IOS Rest DataSanp Client ? [Edit]
I really need Demo for Res DataSnap Server (connect to mySql /msSql) and a IOS Rest DataSanp Client. But I can't not find any? Why? Mainly, I need to know how to add, delete, update records on IOS Rest DataSanp Client. Anyone could provide a hint.!!! Mitchell Hu Edited by: Mitchell Hu on May 24, 2013 12:17 PM Edited by: Mitchell Hu on May 24, 2013 12:22 PM ...

Delphi REST client. How to pass a parameter with Content-Type header. [Edit]
I have a REST Service that am trying to interact with that needs the content type to look like this: Multipart/related; type="application/json"; start="startpart"; boundary="foo" What is the best way to build a header parameter that looks like the above using TRESTClient and TRestRequest. Thanks in advance Edited by: Allen Noland on Apr 5, 2014 6:07 PM ...

Delphi XE2 DataSnap Server
I'm building an XE2 DataSnap server which will serve connections from REST clients. My DSServerClass LifeCycle property is set to 'Invocation'. What I want to do is to log the details of all client connections to the server, including the following details : username, IP address, protocol, application name. I can currently get these details using the following events : DSAuthenticationManager - UserAuthenticate() : username, protocol (using the standard parameters passed in) DSServer - Connect() : protocol, IP address, application name (using DSConnectEventObject.ChannelInfo.ClientInfo) What I want to do is just log once for all details, but it seems I can't get all the details I need in one event. I tried using a shared private variable in the class but as expected this gave inconsistent results - the wrong IP address against the wrong username. Is there another way to achieve what I want? Thanks, Jonathan Managed to solve this by accessing the username in the DSServer Connect event as follows : Session := TDSSessionManager.GetThreadSession; User := Session.UserName; Jonathan ...

Iphone monotouch client <-> Delphi 2010 datasnap server
So, Monotouch has been released and it is now simpler to get into making iphone apps (and soon also android apps). But what is the easiest way to tie an monotouch developed iphone client to a delphi 2010 datasnap server? Any ideas? Rant: "Monotouch" should have been a delphi tool. Then it would have flown of the shelves! But noooo. Not even in the next version is such fat clients and native compiled enviroments catered for. Instead there are talks about linux, mac os, etc. *sigh* Rants are not productive and kill one's desire to be helpful. Fortunately, I decided to...

Create C# proxy for datasnap REST server fails on XE3
I followed this guide: When I try to fetch the proxy I just get a 404 error. http://localhost:8080/proxy/ gives a 404 error and I tried downloading using the command line tool and it also reports 404. What's up? EDIT: NEVERMIND, it seems to work.. Edited by: Anders Andersen on Oct 9, 2012 3:09 PM ...

DataSnap : client switches from dead server to alive server
I am very new of this thing: DataSnap , client-server application. I need solution about 2 servers. When one of them crashes, client just gets error message and user simply changes to another server, such as type 'server name'. First, I use 'LoadParamsFromIniFile' every time I start to connect, but it does not work. Anyone can show me some lines of code to solve my problem or some suggestions? PS. I am using XE3 with embedded component. Thank you Hi there, I just got an answer by doing this:- declare.... private { Private declarations } ...

XE Datasnap Client expection with a XE2 DataSnap Server.
I have developed a simple DataSnap Server on XE2 and the client that connects to this server is under XE. Everything works just fine except when freeing the ClientProxy Module on the client side I get the following exception " TDXError with message Invalid Ordinal 3." followed by a AV. Any hints how to avoid this exception or the Server must be on XE also? Thanks in Advance, Omar Zelaya I have now the DataSanp Server on XE and the client no longer throws the exception. So the question now is, it is possible to use a XE DataSnap Client with a XE2 DataSnap Se...

automation server to client and client to server
I have to applications that need to communicate with each other. Is it practical for both of them to be servers and clients to each other? One of the applications will work primarily as a server and will launch the other application. The newly launched application needs to be able to send occasional information to the server to update information in the application that launched it. Also, if the user attempts to close the launched application it needs to tell the launcher application to close the appl ication that it launched. Does this sound practical? This is kind of like launching wo...

have image go to server other than imaging server?
Hi, we just installed a new netware server with loads more storage capacity than our current server running zenworks. What I want to do is have the images go directly to this newest server, but not have zenworks on it. is there a way to do this? when I go into console one and specify the server and path I want the image to go to it fails because that is not actually the imaging server. When I try to put in the imaging server for the server, but the path to the other server, it fails. how can I run all of the imaging and dhcp stuff on one server, but have my workstations save...

How can I use a linux server as a proxy between a DataSnap server/client
I have a DataSnap Server that is behind a NAT firewall. I also have many DataSnap clients that need to connect to that server. I want to provide a connection proxy to help those two computers connect and transfer data. The server will be authorized for this service ahead of time and I thought the best way would be to have a dedicated port on my Linux servers IP for each server needing my connection service. I have thought about L2TP type of VPN connection from the server to my linux server. It would be nice if I could create scripts/batch files on both ends to automate the install and make th...

Web resources about - DataSnap/REST - Upload image from client to server. [Edit] - embarcadero.delphi.webservices

Companies Directory - Job Fusion
D1 Locker D2L D4D Technologies DAA Deutsche Auftragsagentur Dabble Dabble DB Dabee Dabizmo DabKick Dabo Health Dacentec Dachis Group ...

Embarcadero Webinars
Advanced software tools for application developers and database professionals. Cross-platform solutions for database design, development and ...

David I - Head is in the cloud, feet planted firmly in the ground
... I’s (David Intersimone) Embarcadero blog about programming, languages, databases, history, and more. , and filed under Cloud Computing , DataSnap ...

RAD Studio 2015 Roadmap
Rad Studio, Delphi, C++Builder, and Appmethod 2015 Technology Roadmap from JT at EmbarcaderoTechnologies

FireMonkey Q&A
Questions and answers from a FireMonkey webinar

Contact Us - Ginktage
Home Privacy Policy Contact Us Home .NET Events Microsoft Office SQL Server Tools Gadgets Technology Tips&Tricks Contact Us Ginktage Learn , ...

News Briefs: December 15, 2008 - SD Times: Software Development News
AccuSoft creates an SDK for Web imaging software, while Artisan releases a free version of Artisan Studio. Also, Bredex, Embarcadero, Ilog and ...

Craig Stuntz’s Weblog : Site Map
Craig Stuntz’s Weblog F# • Compilers • Programming Languages • Functional Programming • Web Skip to content Home About Site Map Site Map Share ...

iBeacon Hack Makes It More Efficient To Wait Tables
Here at the 2014 TechCrunch Disrupt SF hackathon two-man hack team, Ray Ho and Mark Watson, showed off a simple but promising concept that combines ...

Te Waka o Delphi · Poll Archives
Keeping Delphi afloat in Aotearoa

Resources last updated: 2/17/2016 12:35:36 PM