Jump to content

DidierXT

Members
  • Content Count

    50
  • Joined

  • Last visited

Everything posted by DidierXT

  1. DidierXT

    Background uploading files

    I need to send several binary files to a (RO) server. The files are located on the user computer or phone. The connexion is not so good and I need the sending to occur in a background sending queue. I've found topic about the sending https://forums.smartmobilestudio.com/topic/4111-upload-image-to-rest-server/ But I wonder if and how I can load the binary from a given file name (\fakepath?). Or do I have to chain several (low) level Http requests https://talk.remobjects.com/t/file-upload-using-http-post/6116/2 Please excuse my confusion, but I've read that file management with PhoneGap is somewhat unified with NodeJS. Nice. But what about file management on web clients ?
  2. DidierXT

    Using WriteLn in WebWorkerThread

    SmartCL.System is required to use WriteLn. But this unit is not allowed inside a WebWorkerThread unit. Is there another way to output logs?
  3. DidierXT

    RemObjects and WebWorkers

    Seems the RO interface need an update following changes in RTL files organization. To be able to execute run a TWebWorkerThread, I had to remove SmartCL.System and W3System units from RemObjectsSDK.pas Unknown "window" error. But now calling RO services still fail with this message: Uncaught ReferenceError: RemObjects is not defined
  4. I didn't find where to customize colors for block delimiters: begin, end, (, [, { Also "lambda" is not included, neither associated with "end".
  5. DidierXT

    File tabs

    Better distinguish the active tab.
  6. DidierXT

    WebWorker project template

    Change the default Javascript file name to worker.js
  7. DidierXT

    WebWorker demo

    I'm trying to run the WebWorker main sample without success. OnMessage is never triggered. Any idea?
  8. DidierXT

    WebWorker demo

    Excellent, works fine! A suggestion for our better understanding (and for the fun): Add a "Disconnect" button. procedure TForm1.W3Button1Click(Sender: TObject); begin // if not properly destroyed // the worker thread may continue its life in parallel of new ones // and still report its work! FWorker := nil; EnableButtons; end;
  9. DidierXT

    Working with images in the file system? 

    Was the previous code (with asm) worked for you? Can you try into TForm1.InitializeForm?
  10. DidierXT

    Working with images in the file system? 

    W3C.File
  11. DidierXT

    Working with images in the file system? 

    And shorter without asm: edPhoto1.InputType := itFile; edPhoto1.Handle.ReadyExecute( procedure () begin w3_setAttrib(edPhoto1.Handle, 'accept', 'image/*'); w3_setAttrib(edPhoto1.Handle, 'capture', ''); edPhoto1.OnChanged := procedure(sender:TObject) begin var reader := JFileReader.Create; reader.onload := lambda imgPhoto1.handle.src := reader.result; end; reader.readAsDataURL(JBlob(edPhoto1.handle.files[0])); end; end);
  12. DidierXT

    WebWorker demo

    I've updated to 3.0.0.206 yesterday. I've also deleted WebWorker directory and updated again. Only manipulation is: copy worker.js from \output to \www folder.
  13. DidierXT

    WebWorker demo

    worker.js:3422 Uncaught ReferenceError: window is not defined (anonymous) @ worker.js:3422 InitAnimationFrameShim @ worker.js:3429 (anonymous) @ worker.js:4593
  14. DidierXT

    WebWorker demo

    The project is defined with "customer server" option, and my default browser is chrome. I tried Mozilla too.
  15. DidierXT

    Working with images in the file system? 

    @lynkfs helped me with this procedure: edPhoto1.InputType := itFile; edPhoto1.Handle.ReadyExecute( procedure () begin w3_setAttrib(edPhoto1.Handle, 'accept', 'image/*'); w3_setAttrib(edPhoto1.Handle, 'capture', ''); edPhoto1.OnChanged := procedure(sender:TObject) begin var reader: variant; asm @reader = new FileReader(); end; reader.onload := lambda imgPhoto1.handle.src := reader.result; end; reader.readAsDataURL(edPhoto1.handle.files[0]); end; end);
  16. DidierXT

    TypeError - Converting circular structure to JSON 

    Hum, seems I misunderstood the whole webworker process... I have to implement the "webworker.js" But I'm unable to have the OnMessage triggered in the démo project. Any idea ?
  17. Hi, I don't understand then reason with of this error. Any idea please? Thanks ////// GLOBAL ////// type TFichier = class(JObject) nom : string; data : string; end; //************* FORM ************* // file informations var fichier := new TFichier; fichier.nom := edPhoto1.Text; fichier.data := imgPhoto1.ToDataUrl; // POST message to threaded webworker var up := TUploadThread.Create(); BrowserAPI.Window.postMessage(fichier, '*'); //************* WEBWORKERTHREAD ************* procedure TUploadThread.ReceiveMessage(Data: Variant); var bd : TBinaryData; begin var fic := TFichier(Data); bd := TBinaryData.Create(); bd.AppendBytes(TDataType.StringToBytes(fic.data)); FROServeur.GetServerTime( procedure (aResult: DateTime) begin writeln('Connexion serveur (thread): ' + aResult.toDateString); FROServeur.AddPhoto( '', fic.nom, bd, // <<<<<<<<==== ??? procedure (aResult: AnsiString) begin Writeln('Fichier: ' + fic.nom + ' : sent !'); end, procedure (aMessage: TROMessage; aError: JError) begin Writeln('Fichier: ' + fic.nom + ' : ' + aError.name + ' - ' + aError.message); //************* TypeError - Converting circular structure to JSON ************* end ); end, procedure (aMessage: TROMessage; aError: JError) begin writeln('Connexion serveur (thread) : IMPOSSIBLE'); end);
  18. DidierXT

    TypeError - Converting circular structure to JSON 

    Note that I use a TWebWorkerThread. I tried, with no success. The PostMessage implementation is void in SmartCL.Webworker.pas .
  19. DidierXT

    Background uploading files

    Thanks Lynkfs, I've made progress, but I think you have misunderstood my goal. I want the selected picture (user computer/phone) to be sent to the server. So no \image directory involved. I just need its binary data... Anyway, it should be ok, although I still have to use JS for several reasons. These events are never triggered: edPhoto.Handle.OnChanged := procedure (event: variant) // (BTW, no RTL reference to OnChange) edPhoto.Handle.OnChanged := procedure() edPhoto.Handle.OnChange := procedure (event: variant) edPhoto.Handle.OnChange := procedure() These ones are working fine: edPhoto.Handle.addEventListener('change', procedure (event: variant) edPhoto.Handle.addEventListener('change', procedure ( ) So here is a working sample [SOLVED]. It would be nice if we could get rid off the asm block, and simplify a bit the whole process. edPhoto1.InputType := itFile; edPhoto1.Handle.ReadyExecute( procedure () begin if w3_getIsMobile then w3_setAttrib(edPhoto1.Handle, 'accept', 'image/png,image/jpg') else w3_setAttrib(edPhoto1.Handle, 'accept', 'image/*'); w3_setAttrib(edPhoto1.Handle, 'capture', ''); edPhoto1.Handle.addEventListener('change', procedure (event: variant) begin writeln('OnChange'); writeln(edPhoto1.handle.files[0].name); var img : variant := new JObject; img := imgPhoto1.Handle.id; asm var reader = new FileReader(); reader.onload = function(){ var data = reader.result; var output = document.getElementById(@img); output.src = data; } reader.readAsDataURL(event.target.files[0]); end; end); end);
  20. DidierXT

    Background uploading files

    Here is the JS script I would like to reproduce. But seems they're is no event object available... <input type='file' accept='image/*' onchange='openFile(event)'><br> <img id='output'> <script> var openFile = function(event) { var input = event.target; var reader = new FileReader(); reader.onload = function(){ var dataURL = reader.result; var output = document.getElementById('output'); output.src = dataURL; }; reader.readAsDataURL(input.files[0]); }; </script>
  21. DidierXT

    Background uploading files

    I 'm unable to retrieve FileList. => Uncaught TypeError: Cannot read property 'slice' of null Full test project is attached. uses W3C.DOM, W3C.File; procedure TForm1.InitializeForm; begin inherited; edPhoto.InputType := itFile; edPhoto.Handle.ReadyExecute( procedure () begin w3_setAttrib(edPhoto.Handle, 'accept', 'image/png,image/jpg'); w3_setAttrib(edPhoto.Handle, 'capture', ''); // inline callback w3_AddEvent(edPhoto.Handle, 'click', procedure() var filelist : JFileList; begin var reader := new JFileReader; reader.onload := function (e: JEvent): Variant begin var dataURL := reader.result; imgPhoto.LoadFromURL(dataURL); result := true; end; //var filelist := JFileList(event.target.files); asm @filelist = event.target.files; end; reader.readAsArrayBuffer(filelist.item(0).slice); end, FALSE ); // separated callback //w3_AddEvent(edPhoto.Handle, 'click', @OnSelectImage, FALSE); end ); end; //procedure TForm1.SelectImage(event: Variant); procedure TForm1.OnSelectImage; var filelist: JFileList; begin var reader := new JFileReader; reader.onload := function (e: JEvent): Variant begin var dataURL := reader.result; imgPhoto.LoadFromURL(dataURL); result := true; end; //var filelist := JFileList(event.target.files); asm @filelist = event.target.files; end; reader.readAsArrayBuffer(filelist.item(0).slice); // => Uncaught TypeError: Cannot read property 'slice' of null [line #16957] end; ImgUploader.zip
  22. DidierXT

    Background uploading files

    I still have to test, but I've found a way I'm using a TImage to store the data before form validation.
  23. DidierXT

    graph

    Nice tool! You could provide masks to generate nodes automatically from knowledge databases or ERP. A few suggestions: - bidirectional connections (ie: "is a friend of") - click to add or remove snippet from the story-line - collapsible nodes
  24. DidierXT

    Background uploading files

    Very useful informations, thanks! I've gone the web-worker path. Indeed the messaging part is full of potential. Still, how can I get (FileReader?) the content of the selected file? I don't want the file to be sent directly after selection (on change), only after manual validation of the form.
  25. DidierXT

    PhoneGap and RO

    Hi Jarto, I have already been able to produce a PhoneGap following your sample. Access origin is correctly set, but it won't work... I have a short dead line, so for the moment I stick with a web mobile client. I'll try to come back to you a bit later with a test project RO+SMS for investigation. Thanks
×