How to send a .tar file to flow service from a DSP page by invoking a IS service

Hi All,

I have a requirement to send a .tar file to IS flow service. i would like to check with you guys, is this possible with webMethods. Below is the code i wrote to send the .tar file to IS service.

dnd binary upload alert("hello"); function sendFile(file) { alert("hello1"); const uri = "http://host:port/invoke/TEST/reprocessFiles"; const xhr = new XMLHttpRequest(); const fd = new FormData();
        xhr.open("POST", uri, true);
	xhr.setRequestHeader("Content-Type", "application/octect-stream");
       xhr.onreadystatechange = function() {
            if (xhr.readyState == 4 && xhr.status == 200) {
                alert("INSIDE IF 200"+xhr.responseText); // handle response.
            }

else{
alert(“ERROR IN CALLING SERVICE”);
}
};
fd.append(‘myFile’, file);

        // Initiate a multipart/form-data upload

alert(“INSIDE APPEND FILE DATA”+fd);
xhr.send(fd);
}

    window.onload = function() {
        const dropzone = document.getElementById("dropzone");
        dropzone.ondragover = dropzone.ondragenter = function(event) {
            event.stopPropagation();
            event.preventDefault();
        }

        dropzone.ondrop = function(event) {

alert(“helloo2”);
event.stopPropagation();
event.preventDefault();

            const filesArray = event.dataTransfer.files;
	alert("LENGTH"+filesArray.length);
            for (let i=0; i<filesArray.length; i++) {
               alert("FILE ARRAY"+filesArray[i]);
            var reader = new FileReader();     
	sendFile(reader.readAsText(filesArray[i]));
            }
        }
    }
</script>
Drag & drop your file here...

Below are the queries i have.

  1. what is the content type i need to use to send this .tar file.
  2. In the flow service what is the input i need to define to receive this file and once i received the content how to extract the files from the .tar file.

Kindly throw some pointers to move forward on this subject.

Thanks & Regards,
Harish Babu.M

Hi Harish

“byte array”/ bytes object would be the right input to your flow service from what I understood of your requirement. For this, “application/octect-stream” is the right content-type. However, for opening the .tar (unarchiving) and reading files inside, there are no public APIs or utility services out of the box from webMethods integration server. There are some third party utilities packages like PSUtilities where you can get access to utility services like zip/unzip or archive/unarchive etc…

Harish, I also have some design related questions:

  • What is the usual size of these .tar files you/enterprise are planning to upload? If the sizes are big then, IMHO, I say this might be a misleaded way of implementation w.r.t software design patterns.
  • If you would like to just drop a file and feed it into a flow service as input, then why not use webMethods file polling ports to achieve the same? One can simply drop a file in some dedicated folder location and configure file polling port to read it and submit to a flow service.
  • If the restriction for file polling port is that your end users do not have access to folder locations on premise, then you can simply use DSP to just let the user upload the file and drop it into a dedicated folder location on premise using DSP. Later, file polling port can kick in and call flow service.