mazluta
Members-
Content Count
38 -
Joined
-
Last visited
Community Reputation
0 NeutralRecent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
upload file to the server for indexing in the server using browser UNIGUI application
mazluta replied to mazluta's topic in Network, Cloud and Web
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 -
upload file to the server for indexing in the server using browser UNIGUI application
mazluta replied to mazluta's topic in Network, Cloud and Web
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 -
upload file to the server for indexing in the server using browser UNIGUI application
mazluta replied to mazluta's topic in Network, Cloud and Web
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. -
upload file to the server for indexing in the server using browser UNIGUI application
mazluta posted a topic in Network, Cloud and Web
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? -
Error sending data: (12029) A connection with the server could not be established.
mazluta replied to mazluta's topic in Network, Cloud and Web
Thanks @Olli73 i will try it -
Error sending data: (12029) A connection with the server could not be established.
mazluta replied to mazluta's topic in Network, Cloud and Web
Hi. thanks for your answer. i close the Firewall. i close the AV. i add inbound roll to open port TCP 8090 for CORS it should "Ask" the server in the local for permition and i respond "OK" for CORS, but it did not rich to this "question". i even don't know what is blocking? where is it blocking? who is blocking> -
Error sending data: (12029) A connection with the server could not be established.
mazluta posted a topic in Network, Cloud and Web
i have rest server witch listen to port 8090. it suppose to get JSON with some params. i have web APP that run in some domain - www.hanibaal-test.co.il the server is in localhost :8090 on the client side i do : procedure TSignedDocumentsFrm.DoSignDocument_CA(PdfFileName : String); var HttpClient : TNetHTTPClient; Response : IHTTPResponse; JsonData : TStringStream; AppUrl : String; ResultPdfFileName : String; SignServerAddress : String; PdfBase64 : String; JpgBase64 : String; EncrtpPassWord : String; begin PdfBase64 := dm_Image.ImgToBase64(PdfFileName); JpgBase64 := dm_Image.ImgToBase64(UniMainModule.UserDataRec.User_Logo_FileName); EncrtpPassWord := EncryptStringCK(UniMainModule.UserDataRec.User_TokenPassword, AppEncryPass); JustWriteToLog('EncrtpPassWord = ' + EncrtpPassWord); SignServerAddress := UniMainModule.UserDataRec.User_CA_Sign_HttpAddrs + ':' + IntToStr(UniMainModule.UserDataRec.User_CA_Sign_Port) + '/sign'; JustWriteToLog('SignServerAddress : ' + SignServerAddress); Try JsonData := TStringStream.Create('{"PdfBase64Type": "base64", ' + ' "PdfBase64": "' + PdfBase64 + '", ' + ' "JpgBase64Type": "base64",' + ' "JpgBase64": "' + JpgBase64 + '", ' + ' "LogoTop": ' + IntToStr(UniMainModule.UserDataRec.User_Logo_Top) + ',' + ' "LogoLeft": ' + IntToStr(UniMainModule.UserDataRec.User_Logo_Left) + ',' + ' "LogoWidth": ' + IntToStr(UniMainModule.UserDataRec.User_Logo_Width) + ',' + ' "LogoHeight": ' + IntToStr(UniMainModule.UserDataRec.User_Logo_Height) + ',' + ' "CheckTokenStr": "' + UniMainModule.UserDataRec.User_Token_SerialNO + '",' + ' "CardSerialNO": "' + UniMainModule.UserDataRec.User_Token_SerialNO + '",' + ' "EncrptPassword": "' + EncrtpPassWord + '",' + ' "ReasonToSign": "' + UniMainModule.UserDataRec.User_SignReason + '",' + ' "ImageOpacity": ' + IntToStr(UniMainModule.UserDataRec.User_ImageOpacity) + '}', TEncoding.UTF8); AppUrl := UniApplication.UniSession.URL; if AppUrl[Length(AppUrl)] = '/' then begin AppUrl[Length(AppUrl)] := ' '; AppUrl := Trim(AppUrl); end; HttpClient := TNetHTTPClient.Create(nil); //HttpClient.CustomHeaders['Origin'] := AppUrl;; HttpClient.CustomHeaders['Content-Type'] := 'application/x-www-form-urlencoded'; HttpClient.PreemptiveAuthentication := true; JustWriteToLog('After Set HttpClient Origin to : ' + AppUrl); // Set request content type to JSON HttpClient.ContentType := 'application/json'; //HttpClient.Accept := 'application/json'; // Send POST request with JSON data JustWriteToLog('Before Post Data to Server'); JustWriteToLog('JsonData = ' + JsonData.ToString); Response := HttpClient.Post(SignServerAddress, JsonData); // Check response if Response.StatusCode = 200 then begin ResultPdfFileName := RemoveBackSlashChar(UniServerModule.LocalCachePath) + '\MyResult.Pdf'; Base64ToPDF(Response.ContentAsString,ResultPdfFileName); //JustWriteToLog(Response.ContentAsString); //ShowMessage('Response: ' + Response.ContentAsString); end else begin ShowMessage('Error: ' + Response.StatusText); end; finally JsonData.Free; HttpClient.Free; end; end; on the server side i have : procedure TMyWebModule.WebModuleBeforeDispatch(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); begin JustWriteToLog('start dispath'); JustWriteToLog('Request.Method = ' + Request.Method); Response.CustomHeaders.Values['Access-Control-Allow-Origin'] := '*'; Response.CustomHeaders.Values['Access-Control-Allow-Headers'] := 'Origin, X-Requested-With, Content-Type, Accept'; Response.CustomHeaders.Values['Access-Control-Allow-Methods'] := 'GET, POST, PUT, DELETE, OPTIONS'; Response.CustomHeaders.Values['Access-Control-Allow-Credentials'] := 'true'; Response.CustomHeaders.Values['Access-Control-Allow-Private-Network'] := '*'; Response.CustomHeaders.Values['Access-Control-Expose-Headers'] := ''; Response.CustomHeaders.Values['Access-Control-Max-Age'] := '86400'; JustWriteToLog('On WebModuleBeforeDispatch - After Set Response.SetCustomHeader Access-Control-Allow-Origin' ); if Trim(Request.GetFieldByName('Access-Control-Request-Headers')) <> '' then begin JustWriteToLog('On WebModuleBeforeDispatch - Trim(Request.GetFieldByName(Access-Control-Request-Headers))'); Response.CustomHeaders.Values['Access-Control-Allow-Headers'] := Request.GetFieldByName('Access-Control-Request-Headers'); Handled := True; end; if SameText(Request.Method, 'OPTIONS') then begin JustWriteToLog('On WebModuleBeforeDispatch - if SameText(Request.Method, Option)'); Response.StatusCode := 204; // No Content Handled := True; end; end; something is blocking the request. and i don't no what.... i close firewall + AV i don't see where and who block my call i don't get any message in the logs (not in the client and not in the server), except "...connection can not be...." i don't see any error in the console.log. When I run both app in my localhost - all work fine and i get CA digital Sign PDF File -
The image in the target mail don't respect the height/width prop
mazluta replied to mazluta's topic in Indy
you right. sorry. PngGraphic := TPngGraphic.Create; try DibGraphic := TDibGraphic.Create; try Result := Base64ToImg(Base64Str, DibGraphic, FileExtn); if not Result then Exit; PngGraphic.Assign(DibGraphic); finally DibGraphic.Free; end; if PngGraphic.Empty then Exit; did you read the TAO? it's old as the wheel of time...... -
The image in the target mail don't respect the height/width prop
mazluta replied to mazluta's topic in Indy
Thanks Remy. no doubt your code is more efficient. but on save the base64 as PNG is not the right way. the base 64 is string depend on the file type. i work with Envision https://www.intervalsoftware.com/envision.html So i load any one of the type with appropriate object and convert it all to PNG, create the PNG, load it to the Html Files of the mail body and send the mail. You are the MASTER. UDDF - Tao of Programming.mht -
The image in the target mail don't respect the height/width prop
mazluta replied to mazluta's topic in Indy
yeeee that abug yes. you right 🙂 -
The image in the target mail don't respect the height/width prop
mazluta replied to mazluta's topic in Indy
Ok. That Work. function Tdm_Image.DoFixMailTextBody(MAIL_TextBody : String; Attach_Base64 : TStringList) : String; Var CurTry : Integer; CurPos : Integer; CurChar : Integer; UniqueNo : Integer; StartFrom : Integer; EndTo : Integer; Base64Str : String; base64 : TBase64Encoding; StrArray : TBytes; DibGraphic : TDibGraphic; TmpPNG : TPngGraphic; TestStr : String; fTempDir : String; PngFileName : String; NewImgSrc : String; FileExtn : String; begin Result := MAIL_TextBody; Attach_Base64.Clear; CurTry := 0; While CurTry < 250 Do begin CurTry := CurTry + 1; FileExtn := ''; FileExtn := 'png'; CurPos := pos(Base64_01,MAIL_TextBody); if CurPos < 1 then begin FileExtn := 'jpg'; CurPos := pos(Base64_02,MAIL_TextBody); end; if CurPos < 1 then begin FileExtn := 'svg'; CurPos := pos(Base64_03,MAIL_TextBody); end; if CurPos < 1 then begin FileExtn := 'png'; CurPos := pos(Base64_04,MAIL_TextBody); end; if CurPos < 1 then begin FileExtn := 'jpg'; CurPos := pos(Base64_05,MAIL_TextBody); end; if CurPos < 1 then begin FileExtn := 'bmp'; CurPos := pos(Base64_06,MAIL_TextBody); end; if CurPos < 1 then begin FileExtn := 'gif'; CurPos := pos(Base64_07,MAIL_TextBody); end; if CurPos < 1 then begin FileExtn := 'tif'; CurPos := pos(Base64_08,MAIL_TextBody); end; if CurPos < 1 then begin FileExtn := 'wmf'; CurPos := pos(Base64_09,MAIL_TextBody); end; if CurPos < 1 then begin FileExtn := 'emf'; CurPos := pos(Base64_10,MAIL_TextBody); end; if CurPos > 0 then begin UniqueNo := GetUniqueNumber; {This will be tje dic Number} StartFrom := 0; EndTo := 0; // first find the , char - after that start the base64 string For CurChar := CurPos + 5 to Length(MAIL_TextBody) Do begin if MAIL_TextBody[CurChar] = ',' then begin StartFrom := CurChar + 1; Break; end; end; // the find the next " char - this close the base64 string For CurChar := StartFrom + 5 to Length(MAIL_TextBody) Do begin if MAIL_TextBody[CurChar] = '"' then begin EndTo := CurChar - 1; Break; end; end; // take the Base64 String And Convert to png file DibGraphic := TDibGraphic.Create; Try fTempDir := RemoveBackSlashChar(RemoveSlashChar(UniServerModule.LocalCachePath)); Base64Str := Copy(MAIL_TextBody,StartFrom, EndTo - StartFrom); if Base64ToImg(Base64Str,DibGraphic, FileExtn) then begin PngFileName := fTempDir + '\' + IntToStr(UniqueNo) + '.png'; TmpPNG := TPngGraphic.Create; Try TmpPNG.Assign(DibGraphic); TmpPNG.SaveToFile(PngFileName); Attach_Base64.Add(PngFileName); Delete(MAIL_TextBody, CurPos + 5, EndTo - CurPos - 4); NewImgSrc := 'cid:' + IntToStr(UniqueNo) +'.png'; Insert(NewImgSrc, MAIL_TextBody, CurPos + 5); Finally FreeAndNil(TmpPNG); End; end; Finally FreeAndNil(DibGraphic); End; end else begin Break; end; end; Result := MAIL_TextBody; end; and to send the Mail : function SendMailBySMTP(SMTP_Host : String; SMTP_User : String; SMTP_Password : String; SMTP_Port : Integer; Send_FromAddress : String; Send_FromName : String; Send_ToAddress : String; Send_ToName : String; Send_Subject : String; Send_TextBody : String; UseCid : Boolean; Attach_Base64 : TStringList; Attach_List : TStringList) : Boolean; Var cid : WideString; SMTP : TIdSMTP; AMsg : TidMessage; CurAttch : Integer; FoundBase64 : Boolean; Const Base64_01 : String = 'src="data:image/png;base64,'; Base64_02 : String = 'src="data:image/jpeg;base64,'; Base64_03 : String = 'src="data:image/image/svg+xml;base64,'; Base64_04 : String = 'src="data:image/image/apng;base64,'; Base64_05 : String = 'src="data:image/jpg;base64,'; Base64_06 : String = 'src="data:image/image/bmp;base64,'; Base64_07 : String = 'src="data:image/image/gif;base64,'; Base64_08 : String = 'src="data:image/image/tiff;base64,'; Base64_09 : String = 'src="data:image/image/wmf;base64,'; Base64_10 : String = 'src="data:image/image/emf;base64,'; begin Result := False; Try if UseCid Then begin FoundBase64 := False; if (pos(Base64_01,Send_TextBody) > 0) Or (pos(Base64_02,Send_TextBody) > 0) Or (pos(Base64_03,Send_TextBody) > 0) Or (pos(Base64_04,Send_TextBody) > 0) Or (pos(Base64_05,Send_TextBody) > 0) Or (pos(Base64_06,Send_TextBody) > 0) Or (pos(Base64_07,Send_TextBody) > 0) Or (pos(Base64_08,Send_TextBody) > 0) Or (pos(Base64_09,Send_TextBody) > 0) Or (pos(Base64_10,Send_TextBody) > 0) then FoundBase64 := True; if not FoundBase64 Then UseCid := False; end; if UseCid then begin end; Try SMTP:= TIdSMTP.Create(nil); SMTP.Disconnect(); SMTP.Host := SMTP_Host; SMTP.Username := SMTP_User; SMTP.Password := SMTP_Password; SMTP.Port := SMTP_Port; AMsg := TidMessage.Create(nil); AMsg.Encoding := meDefault; AMsg.ContentType := 'text/html'; if Attach_List.Count > 0 then AMsg.ContentType := 'multipart/mixed'; AMsg.CharSet := 'UTF-8'; //AMsg.ContentTransferEncoding := '8bit'; AMsg.subject := UTF8Encode(Send_Subject); AMsg.From.Name := UTF8Encode(Send_FromName); AMsg.From.Address := Send_FromAddress; with AMsg.Recipients.Add do begin Name := UTF8Encode(Send_ToName); Address := Send_ToAddress; end; with TIdMessageBuilderHtml.Create do try HtmlCharSet := 'UTF-8'; Html.Text := UTF8Encode(Send_TextBody); if Attach_List.Count > 0 then begin for CurAttch := 0 To Attach_List.Count - 1 Do begin Attachments.Add(Attach_List.Strings[CurAttch]); end; end; if Attach_Base64.Count > 0 then begin for CurAttch := 0 To Attach_Base64.Count - 1 Do begin HtmlFiles.Add(Attach_Base64.Strings[CurAttch]); end; end; FillMessage(AMsg); finally Free; end; SMTP.Connect; SMTP.Send(AMsg); Result := True; Finally AMsg.Free; SMTP.Disconnect; SMTP.Free; End; Except on E: Exception do begin AddMsgToEventLog('', J_FirstFileName(ParamStr(0)), 'Fail send SMPT Mail, Error :' + e.Message,EVENTLOG_ERROR_TYPE, 4, 1); Result := False; end; End; end; function IsTherBase64InHTML(HTML_Text : String) : Boolean; Const Base64_01 : String = 'src="data:image/png;base64,'; Base64_02 : String = 'src="data:image/jpeg;base64,'; Base64_03 : String = 'src="data:image/image/svg+xml;base64,'; Base64_04 : String = 'src="data:image/image/apng;base64,'; Base64_05 : String = 'src="data:image/jpg;base64,'; Base64_06 : String = 'src="data:image/image/bmp;base64,'; Base64_07 : String = 'src="data:image/image/gif;base64,'; Base64_08 : String = 'src="data:image/image/tiff;base64,'; Base64_09 : String = 'src="data:image/image/wmf;base64,'; Base64_10 : String = 'src="data:image/image/emf;base64,'; begin Result := (pos(Base64_01,HTML_Text) > 0) Or (pos(Base64_02,HTML_Text) > 0) Or (pos(Base64_03,HTML_Text) > 0) Or (pos(Base64_04,HTML_Text) > 0) Or (pos(Base64_05,HTML_Text) > 0) Or (pos(Base64_06,HTML_Text) > 0) Or (pos(Base64_07,HTML_Text) > 0) Or (pos(Base64_08,HTML_Text) > 0) Or (pos(Base64_09,HTML_Text) > 0) Or (pos(Base64_10,HTML_Text) > 0); end; thanks Remy for your Help. -
The image in the target mail don't respect the height/width prop
mazluta replied to mazluta's topic in Indy
Thanks. i will try it -
The image in the target mail don't respect the height/width prop
mazluta replied to mazluta's topic in Indy
i see i can build the eMail for Gmail using IDMessage. i can iterate in all base64 img convert them to png file but i dont see way to embedded the image it self into the html message back... -
The image in the target mail don't respect the height/width prop
mazluta replied to mazluta's topic in Indy
ok. now there is new problem. Gmail want show message with image base on base64 string. is there simple convert outlook message to Gmail Message? -
The image in the target mail don't respect the height/width prop
mazluta replied to mazluta's topic in Indy
that work. 1. i remove the html conflict. 2. i gat the return string from the CkEditor. 3. i build simple HTML with 2 function. one to iterate all image. and for each <img> element i convert the base64 to be the same as the attribute (second function). 4. now, when i send the - "message" - its all look "normal".. thank Remy and Alexander. BTW - attach is the HTML file i build to convert the Images mtTag_11197140.html