mazluta 0 Posted November 7 I have a document management system (DMS) written in Delphi UNIGUI. I have a scanning system with many capabilities written in Delphi DESKTOP. I want to scan with the DeskTop application and when finished send the scanned file to the server (Unigui) to perform the filing on the server. The server should receive the file, save it in the temporary area and pop up a filing screen. What is the best way to do it? Share this post Link to post
corneliusdavid 213 Posted November 8 I'm not sure there's a "best" way; there are many options and depending on your time, abilities, security requirements, and possibly other factors, one solution may work better than others. Here are a few suggestions and you can shoot down which ones that won't work for some reason or other: Use a file-sync service (DropBox, pCloud, etc.) then your desktop app can simply save a file to a pre-selected folder and a few moments later it will be synchronized to your server. This would be the quickest and easiest to implement but you may not trust a third-party service. Set up FTP/SFTP on your server with a custom login; then implement SFTP in your desktop app to send the file to that SFTP account. I don't know UniGUI that well but if there's an easy way to provide a URL for HTTP-POST messages, then add that to your server app; your desktop app would then simply send the file in an HTTP-POST message to that URL. You could also write your own custom messaging service, the server side would listen on a specific port and your desktop would send files to that port. But why reinvent FTP? Share this post Link to post
DelphiUdIT 172 Posted November 8 There are too few informations to do a proposal: - they should work inside a LAN, a WLAN, Internet ? - they should work inside an office, a complex structure ? - how many processes will there be? 100 per seconds, 100 per hours ? -etc ... Share this post Link to post
mazluta 0 Posted November 8 (edited) 10 hours ago, corneliusdavid said: I'm not sure there's a "best" way; Hi David. yes, you right. Since the Server (UNIGUI) is always running i thought to use it as "FTP". on the Desktop App var HTTP: TIdHTTP; FormData: TIdMultipartFormDataStream; url : string; FilePath : string; ResultInt : Int64; begin Try HTTP := TIdHTTP.Create(nil); FormData := TIdMultipartFormDataStream.Create; try FilePath := 'c:\a\M1.pdf'; URL := PrmUrlAddress + ':' + IntToStr(PrmUrlPort) + '/Indexing'; ResultInt := GetUniqueNumber; JustWriteToLog('url=' + url); JustWriteToLog('ResultInt=' + IntToStr(ResultInt)); FormData.AddFile('file', FilePath, 'application/octet-stream'); // 'file' is the form field name expected by the server FormData.AddFormField('UniqueName', IntToStr(ResultInt)); HTTP.Post(URL, FormData); // URL is the endpoint, e.g., http://yourserver:port/upload ShowMessage('File uploaded successfully - Status Code = ' + IntToStr(HTTP.ResponseCode)); ShowMessage('Response Text = ' + HTTP.ResponseText); except on E: Exception do ShowMessage('Failed to upload file: ' + E.Message); end; Finally FormData.Free; HTTP.Free; End; and on the server (UNIGUI) Var FileStream: TFileStream; SavePath : string; FileFirstName : String; FormData: TIdMultiPartFormDataStream; begin if ARequestInfo.URI = '/Indexing' then begin FormData := TIdMultiPartFormDataStream.Create; FileFirstName := The Extra PARAM Field SavePath := 'C:\a\' + FileFirstName + '.pdf'; FileStream := TFileStream.Create(SavePath, fmCreate); try // Copy the incoming data to the file stream FileStream.CopyFrom(ARequestInfo.PostStream, ARequestInfo.PostStream.Size); finally FileStream.Free; end; AResponseInfo.ResponseText := 'File Saved OK'; Handled := True; end; end; then after getting 200 status from the server, send another one with the unique no and go to indexing process. Edited November 8 by mazluta Share this post Link to post
mazluta 0 Posted November 8 2 hours ago, DelphiUdIT said: There are too few informations to do a proposal: yes. sorry. office - internet - cloud server. the desktop will be installed in any of the clients 10-50 per day. 5 users. since i new to web development i would like to hear what the masters idea Share this post Link to post
DelphiUdIT 172 Posted November 8 I think you are in the right way. Think about HTTPS transfer and may be a simple login (sending username and password for example). 1 Share this post Link to post
mazluta 0 Posted November 9 this is the solution https://forums.unigui.com/index.php?/topic/36456-upload-file-to-the-server-for-indexing-in-the-server-using-browser-unigui-application/#comment-169303 Share this post Link to post