In fact, I created a web application (JavaScript script) which accepts file upload and submits a job, based on a premise that the Session ID is unique for each session. The function looks like this.
Â
function uploadAndSubmitJob(repository, workspace, fileInput) {
    FMEServer.getSession(repository, workspace, callbackGetSession);
   Â
    function callbackGetSession (obj) {
        var session = obj.serviceResponse.session;
        FMEServer.dataUpload(repository, workspace, fileInput, session, callbackDataUpload);
    }
   Â
    function callbackDataUpload (obj) {
        var session = obj.serviceResponse.session;
        var filename = fileInput.value.replace(/^.* \\/]/, '');
        var parameters = {
            "publishedParameters" : Â
                {
                    "name" : "SOURCE_DATASET",
                    "value" : "$(FME_DATA_REPOSITORY)/<repository>/<workspace>/<session>/<filename>"
                }
            ]
        };
        FMEServer.submitJob(repository, workspace, parameters, function (obj) { });
    }
}
With FME Server 2017.1.2.1, it worked fine since Session ID returned from the FME.getSession function was unique. This is a response of the FME.getSession from FME Server 2017.1.2.1.
Â
Session ID = 5A73001A453ECFFF50F4AD2F50539545
Â
{
    "serviceResponse":{
        "statusInfo":{
            "status":"success"
        },
        "session":"5A73001A453ECFFF50F4AD2F50539545",
        "files":{
            "path":"",
            "folder":E
                {
                    "path":"$(FME_DATA_REPOSITORY)/<repository>/<workspace>/5A73001A453ECFFF50F4AD2F50539545",
                    "name":""
                }
            ]
        }
    }
}
However, in FME 2018.0+, this could cause a wrong result or an error, since the Session ID is equal to User Name (is not unique for each session). I will have to fix the application if the new behavior (Session ID = User Name) was really correct.
Â
It's a very critical issue for my current project. Please confirm whether the new behavior is correct as soon as possible.
Â
Hi @takashi
I have a feeling this is intentional because of some changes coming later in 2018 but I will confirm this for you and update.
Hi @takashi
I have a feeling this is intentional because of some changes coming later in 2018 but I will confirm this for you and update.Â
Thanks for your response.
Â
The application should allow multiple clients to access the FME Server with the same user account and run a job with an uploaded file independently.
Â
In FME 2017.1.2.1, Session ID was unique for each session and the uploaded file will be saved in a directory specific to the session, so I was able to use the session ID to distinguish individual uploads.
Â
However, in FME 2018.0, since Session ID is always equal to the user name and all the uploaded files from the same user account will be saved into the same directory (folder name = user name), the application cannot distinguish individual uploads.
Â
In my test with this simple application and FME 2018.0, the object returned from the FMEServer.dataUpload function contains an array which contains the information on all files saved in a folder with the session name (i.e. user name) at the time.
Â
How can you select which file has been uploaded from the current session in this client?
Â
Or, am I missing something?
Â
<!DOCTYPEÂ html>
<html>
<head><title>FME Server File Upload</title></head>
<body onload="onLoadBody();">
<div>
  <input id="selectFile" type="file" onchange="uploadFile(this);"></input>
</div>
<script type="text/javascript" src="http://api.fmeserver.com/js/v1.1/FMEServer.js"></script>
<script type="text/javascript">
var host = 'http://**********';
var token = '***************************************';
var repository = "Tests";
var workspace = "fme-parameters.fmw";
   Â
function onLoadBody() {
    FMEServer.init({server: host, token: token});
}
function uploadFile(fileInput) {
    FMEServer.getSession(repository, workspace, function (obj) {
        var session = obj.serviceResponse.session;
        //var session = 'RANDOM_VALUE';
        // Even if you assign a random value to session, folder name becomes user name.
        FMEServer.dataUpload(repository, workspace, fileInput, session, function (obj) {
            alert(JSON.stringify(obj));
        });
    });
}
</script>
</body></html><br>
Even if you uploaded just a single file, the response contains the information on all the files saved in the "session" (i.e. user name) folder at the time. You cannot control the folder (session) name from the application. There seems to be no way to distinguish which file has been uploaded from which session / client.
{
    "serviceResponse":{
        "statusInfo":{
            "status":"success"
        },
        "session":"superuser",
        "files":{
            "path":"",
            "file":
                {
                    "size":983,"name":"datadownload_response_json_template.txt"
                },
                {
                    "size":1168,"name":"datetimeconverter-autodetect_log.ffs"
                },
                {
                    "size":45518,"name":"fme-parameters.fmw"
                },
                {
                    "size":59238,"name":"path-reader-unc.log"
                },
                {
                    "size":9479,"name":"sample2.html"
                },
                {
                    "size":237,"name":"subscriber.json"
                }
            ],
            "folder":c
                {
                    "name":""
                }
            ]
        }
    }
}
Hi @takashi
I have a feeling this is intentional because of some changes coming later in 2018 but I will confirm this for you and update.
I think it also causes a problem that a file uploaded into the "user name" folder would be overwritten, if another client with the same user account would upload a file having different content but the same name as the file existing in the folder. Such a conflict cannot be resolved unless the folder name would be unique for each session.
Â
Â
Hi @takashi
I have a feeling this is intentional because of some changes coming later in 2018 but I will confirm this for you and update.
Perhaps this one?
Â
==============================
Â
FME Server 2018.0 "What's New"
Â
==============================
Â
FME 2018.0 b18263 20180206
Â
--------------------------
Â
FME Server Web Services: Added support for Authorization via header. Namespace dataupload service uploads by username instead of jsessionID (PR#81344)
Â
I don't know why this change was necessary, and also I'm afraid that this could cause serious side effects against existing applications using data upload service in conjunction with job submit service.
Â
Hi @takashi
I have a feeling this is intentional because of some changes coming later in 2018 but I will confirm this for you and update.
Â
@takashi These changes were made to implement fault tolerance in FME Server, but I've passed on your comments to development.
Â
This might be worth submitting a support case so that we can record and raise it officially with all of your feedback
Hi @takashi
I have a feeling this is intentional because of some changes coming later in 2018 but I will confirm this for you and update.
Thanks for your consideration. In the interim, I downgrade the FME Server for the project to FME 2017.1.2.1.
Â
Â
Hi @takashi
I have a feeling this is intentional because of some changes coming later in 2018 but I will confirm this for you and update.
I submitted a support case #C135583.
I looked at the source of the "Easy Translator" demo to learn how I can identify a file uploaded in a session.
Easy Translator | FME Server Demos
In my understanding, the app seems to identify selected files with their names simply. If the directory path was unique, the app works fine independently for each session, even if multiple clients (sessions) access at the same time.
However, in FME 2018, session ID is equal to user name and therefore directory path is not unique. I checked the fact with this demo too: Upload File In Session | FME Server Playground
This could cause a conflict in some scenarios. For example, a case where two clients - "A" and "B" operate the "Easy Translator" demo in the following order.
- "A" uploads "sample.zip" which contains a Shapefile dataset, and sets "Esri Shape" to the Source Format parameter.
- "B" uploads "sample.zip" which contains a Mapinfo TAB dataset. The file name is the same as "A"'s, but the contents are different.
- "A" selects the "sample.zip", submits the job, then clicks "Download Results"... oops!
You can reproduce the symptom easily. Try the scenario with the attached sample files:
samples.zipI think Session ID should be unique and the directory path should contain the unique Session ID, in order to allow any application to process uploaded files independently for each session.
This issue has now been fixed in 2018.0.0.1 - Build 18292+
The data upload service now accepts a new parameter, "opt_namespace". If this parameter is specified, uploads will be placed in a folder named after the value of opt_namespace. If the parameter is unspecified, uploads will be placed in a folder named after the username of the uploading user.
If a user has a created a third party application that uses a single token to connect to fme server, it should be recommended that they supply a random number or guid to the opt_namespace parameter.
The FMEServer.js library has been updated to support this change on server:
http://api.fmeserver.com/js/v1.2/FMEServer.js
This issue has now been fixed in 2018.0.0.1 - Build 18292+
The data upload service now accepts a new parameter, "opt_namespace". If this parameter is specified, uploads will be placed in a folder named after the value of opt_namespace. If the parameter is unspecified, uploads will be placed in a folder named after the username of the uploading user.
If a user has a created a third party application that uses a single token to connect to fme server, it should be recommended that they supply a random number or guid to the opt_namespace parameter.
The FMEServer.js library has been updated to support this change on server:
http://api.fmeserver.com/js/v1.2/FMEServer.js
Good to hear. I'll test the new library.
Â
Thanks for the quick fix.
Â
I tested the behavior of getSession and dataUpload in the FMEServer.js Library Version 1.2 and FME Server 2018.0.0.1 build 18295, with this script.
<!DOCTYPEÂ html>
<html>
<head><title>FME Server File Upload</title></head>
<body onload="onLoadBody();">
<div>
  <input id="selectFile" type="file" onchange="uploadFile(this);"></input>
</div>
<div>
    <table>
        <thead><th>Method</th><th>Session ID</th><th>Directory Path</th></thead>
        <tbody id="result" />
    </table>
</div>
<script type="text/javascript" src="http://api.fmeserver.com/js/v1.2/FMEServer.js"></script>
<script type="text/javascript">
var host = 'http://**********************************'; // Replace with your FME Server URL.
var token = '****************************************'; // Replace with you token.
var repository = "Tests"; // Replace with a valid repository name in the server.
var workspace = "fme-parameters.fmw"; // Replace with a valid workspace name in the repository.
   Â
function onLoadBody() {
    FMEServer.init({server: host, token: token});
}
function uploadFile(fileInput) {
    FMEServer.getSession(repository, workspace, function (obj) {
        var res = obj.serviceResponse;
        appendResultRow('getSession', res.session, res.files.folderi0].path);
        // Option 1: Use Session ID returned by the getSession method.
        var session = res.session;
       Â
        // Option 2: Use a string value defined in the client application.
        // var session = 'Custom Session ID';
       Â
        // Option 3: Use the null or the empty string.
        // var session = null;       Â
       Â
        FMEServer.dataUpload(repository, workspace, fileInput, session, function (obj) {
            appendResultRow('dataUpload', obj.serviceResponse.session, '');
        });
    });
   Â
    function appendResultRow(method, session, path) {
        var data = Smethod, session, path];
        var tr = document.createElement('tr');
        for (var i = 0; i < data.length; i++) {
            var td = document.createElement('td');
            td.innerText = data>i];
            tr.appendChild(td);
        }
        document.getElementById('result').appendChild(tr);
    }
}
</script>
</body></html>
In my observation, when the getSession method is called, the FME Server generates a unique identifier (session ID) of 10 digits and creates this directory.
$(FME_DATA_REPOSITORY)/<repository>/<workspace>/<session ID>
Then, the response from the getSession method contains the session ID and the directory path.
Regarding the dataUpload method, there seems to be three options on the 'session' parameter setting.
- Pass the session ID returned by the getSession method. The uploaded file will be saved into the directory which has been created when the getSession method was called. i.e. "$(FME_DATA_REPOSITORY)/<repository>/<workspace>/<session ID>"
- Specify a string value defined in the client application. The uploaded file will be saved into a directory "$(FME_DATA_REPOSITORY)/<repository>/<workspace>/<specified string>".
- Set the null or the empty string. The uploaded file will be saved into a directory "$(FME_DATA_REPOSITORY)/<repository>/<workspace>/<current FME Server user name>".
Is my observation above correct?
This issue has now been fixed in 2018.0.0.1 - Build 18292+
The data upload service now accepts a new parameter, "opt_namespace". If this parameter is specified, uploads will be placed in a folder named after the value of opt_namespace. If the parameter is unspecified, uploads will be placed in a folder named after the username of the uploading user.
If a user has a created a third party application that uses a single token to connect to fme server, it should be recommended that they supply a random number or guid to the opt_namespace parameter.
The FMEServer.js library has been updated to support this change on server:
http://api.fmeserver.com/js/v1.2/FMEServer.js
FME 2018.0.0.1, the new parameter 'opt_namespace' and the new FMEServer.js library version 1.2 seem to work as expected. I upgraded all FME Servers under my management to 2018.0.0.1 build 18295.
Â