Sending images in the clipbaord stream in Guacamole

161 views Asked by At

I have written an application which uses guacamole-lite npm package to create remote connections. I have implemented clipoard from local to remote and remote to local machine as well it only works with text using the guacamole.setClipboard() method. I want to add the functionality of pasting the picture/images as well.

This is the code that I'm trying and i have tried several other methods too:

function retrieveImageFromClipboardAsBlob(pasteEvent){
      var items = pasteEvent.clipboardData.items;
      let blob = "";
      for (var i = 0; i < items.length; i++) {
        blob = items[i].getAsFile();
      }
       return blob;
    }


    window.addEventListener("paste", async function(e){
      // Handle the event
      let imageBlob = retrieveImageFromClipboardAsBlob(e);
      console.log(imageBlob, "image blobbbb");

      console.log(imageBlob.type, "type of image blobbbbb");

      const stream = guac.createClipboardStream("image/jpeg");
      guac.sendBlob(stream);

    }, false);

Can anyone help me where I'm going wrong. I have also tried the writer like this but it doesn't works:

const writer = new Guacamole.ArrayBufferWriter(stream);
writer.sendData(imageBlob);

I have also tried sending the image in Base64 but it doesn't works either

0

There are 0 answers