I've already talked with Mike about this request. I think that the rest API should provide a kind of save function to return a file to the client. A quick way to download a csv file for example based on a request.
From my understanding, file creation can't be done by the client side in JavaScript.
Brian FrankFri 3 May 2013
Every op returns a "file" which can be saved right? Or am I missing something. Is this to push a file to the server, or to do something like download files from the file system?
Mike JarmyFri 3 May 2013
Brian is correct, every op can already specify its format as a mime type. We currently support "text/plain", "text/csv", "text/zinc", and "application/json". So if you want to save something as csv, you would specify that mime type in your request, and then do what ever you want to with the resulting response value on the client side, e.g. saving it to a file yourself.
Christian TremblayFri 3 May 2013
I'll be more precise.
I have a JavaScript app that can retrieve histories. You can choose different histories for a specified range. The script then retrieve the data from haystack doing one request by history. Data is then treated in memory, joined and put in a data table.
The save op I'm talking would be able to accept a post with a string (ex. A csv string) and return a file that the user can download.
This part is required because the file can't be created from the client side (without using flash or something else).
If haystack would be able to handle this part it would be simpler. If not, another server is required only to process files.
Brian FrankMon 6 May 2013
I think I understand what you are saying. You just want to post some arbitrary file to the server temporarily (generated by JS), to download back again. Then the server would be free to delete the file. We actually do something similar to this in SkySpark to implement export. I think this might be slick, but I'm also a little worried about security implications.
Christian TremblayMon 6 May 2013
What would be a secure way of doing this ?
I'm seeing this from the side of very simple javascript apps from wich a client could get a file and save it or open it in Excel...
There is a lot of potential applications :
Site browser / Equipment broswer
Snapshot of building
Reports for equipments / sites
list of rooftop, filters size, etc..
Histories comparison
If not directly in haystack, what would be the best alternative from your experience ?
Brian FrankMon 6 May 2013
The security issue that you are allowing a client to create files on the server that have to be kept for some amount of time until the client requests that file. Like temp files. But I'm not a JS expert, so might need some other opinions on if this is the best way to tackle that problem (or if it even belongs in the haystack standard ops).
Andy FrankMon 6 May 2013
This sounds out of scope of haystack. It's really an application specific thing - so would be better served by whatever web server/system you're using.
Christian Tremblay Fri 3 May 2013
I've already talked with Mike about this request. I think that the rest API should provide a kind of save function to return a file to the client. A quick way to download a csv file for example based on a request.
From my understanding, file creation can't be done by the client side in JavaScript.
Brian Frank Fri 3 May 2013
Every op returns a "file" which can be saved right? Or am I missing something. Is this to push a file to the server, or to do something like download files from the file system?
Mike Jarmy Fri 3 May 2013
Brian is correct, every op can already specify its format as a mime type. We currently support "text/plain", "text/csv", "text/zinc", and "application/json". So if you want to save something as csv, you would specify that mime type in your request, and then do what ever you want to with the resulting response value on the client side, e.g. saving it to a file yourself.
Christian Tremblay Fri 3 May 2013
I'll be more precise.
I have a JavaScript app that can retrieve histories. You can choose different histories for a specified range. The script then retrieve the data from haystack doing one request by history. Data is then treated in memory, joined and put in a data table.
The save op I'm talking would be able to accept a post with a string (ex. A csv string) and return a file that the user can download.
This part is required because the file can't be created from the client side (without using flash or something else).
If haystack would be able to handle this part it would be simpler. If not, another server is required only to process files.
Brian Frank Mon 6 May 2013
I think I understand what you are saying. You just want to post some arbitrary file to the server temporarily (generated by JS), to download back again. Then the server would be free to delete the file. We actually do something similar to this in SkySpark to implement export. I think this might be slick, but I'm also a little worried about security implications.
Christian Tremblay Mon 6 May 2013
What would be a secure way of doing this ?
I'm seeing this from the side of very simple javascript apps from wich a client could get a file and save it or open it in Excel...
There is a lot of potential applications :
If not directly in haystack, what would be the best alternative from your experience ?
Brian Frank Mon 6 May 2013
The security issue that you are allowing a client to create files on the server that have to be kept for some amount of time until the client requests that file. Like temp files. But I'm not a JS expert, so might need some other opinions on if this is the best way to tackle that problem (or if it even belongs in the haystack standard ops).
Andy Frank Mon 6 May 2013
This sounds out of scope of haystack. It's really an application specific thing - so would be better served by whatever web server/system you're using.
Christian Tremblay Mon 6 May 2013
Then, I surrender ! :-)