I would like to upload file programatically to my jsf application. The user should select a directory on his system, and a js script should loop on any file in dir and send each one to the listener serverside
I cannot use FileUpload, because it cannot select a whole dir with thousands of file, so I was thinking to use jquery and send the file to a remotecommand, but I have no clue to how send the file itself (normally I pass just string)
so I was thinking to use jquery and send the file to a remotecommand, but I have no clue to how send the file itself
Don't go there. It is a bad attempt to a workaround for a bad design choice. You'd most likely run into similar problems and what about the user selecting a lot of files for second time if it fails halfway? It might become slow, might run into browser limits (search for uploading multiple files in plain html)...
If you still want to do it via a webbrowser (which according to one of your other questions you do not want to), maybe try something like https://webdeltasync.github.io/ (disclaimer: I did not use it myself, and there might be similar ones (https://www.google.com/search?q=browser+based+rsync), it is just a hint in which direction to find a real solution)
Related
In my karate tests i need to write response id's to txt files (or any other file format such as JSON), was wondering if it has any capability to do this, I haven't seen otherwise in the documentation. In the case of no, is there a simple JavaScript function to do so?
Try the karate.write(value, filename) API but we don't encourage it. Also the file will be written only to the current "build" directory which will be target for Maven projects / stand-alone JAR.
value can be any data-type, and Karate will write the bytes (or plain-text) out. There is no built-in support for any other format.
Here is an example.
EDIT: for others coming across this answer in the future the right thing to do is:
don't write files in the first place, you never need to do this, and this question is typically asked by inexperienced folks who for some reason think that the only way to "save" a response before validation is to write it to a file. No, please don't waste your time - and please just match against the response. You can save it (or parts of it) to variables while you make other HTTP requests. And do not write your tests so that scenarios (or features) depend on other scenarios, this is a very bad practice. Also note that by default, Karate will dump all HTTP requests and responses in the log file (typically in target/karate.log) and also in the HTML report.
see if karate.write() works for you as per this answer
write a custom Java (or JS function that uses the JVM) to do what you want using Java interop
Also note that you can use karate.toCsv() to convert JSON into CSV if needed.
My justification for writing to a file is a different one. I am using karate explicitly to implement a mock. I want to expose an endpoint wherein the upstream system will send some basic data through json payload using POST/PUT method and karate will construct the subsequent payload file and stores it the specific folder, and this newly created payload file will be exposed through another GET call.
I have written a bit of automated code that checks a SharePoint site and looks for a ZIP file (lets call it doc.zip). If doc.zip is found, it downloads it, and then checks for a file (say target.docx). doc.zip is about 300MB, and so I want to only download where necessary.
What I would like to know is that given SharePoint has some ZIP search capability, is it possible to write code using CSOM (c#) to find doc.zip, and then run some code to retrieve the contents of doc.zip without downloading it.
Just to re-iterate, I am comfortable with searching for files in a folder on SP, downloading the file, and unpacking zip entries. What I need is to retrieve a ZIP files content on SP without downloading it.
E.g. is there a SP command:
cxt.Load(SomeZipFileQuery);
cxt.ExecuteQuery();
Thanks in advance.
This capability is not available. I do like the idea. Having the ability to "parse" zip files on the server side and then download the relevant bits would be ideal. Perhaps raise this on uservoice to see if others also find this us https://sharepoint.uservoice.com
Ok, I have proven yet again that stubbornness will prevail.
I have figured out that if I use the /_api/search?query='myfile.zip' web REST API to search for my file, this search will also match ZIP files that contain the file I need. And it works perfectly.
Of course there is added (pain) of parsing an XML response, but it works very nicely for my code example.
At least if someone is looking for this solution here it is. I wont bore anyone with code, as the /_api/search has probably been done to death already on other threads.
I have an xPages application that needs to write a text file to a folder on my network. I'm not sure if it's even possible from an xPages application?
If it is, can someone give me an idea how to go about this?
POI4XPages can write views etc to CSV files https://poi4xpages.openntf.org/. I've previously used OpenCSV, and Apache-licensed Java library to import from a CSV file, but it also allows exporting. I use it regularly to preload data for session databases like for my session at Connect 2016. CommonsCSV has subsequently been released, which would replace OpenCSV.
Yes you can. The easiest way is to create a Java class that does what you need (and test it from the command line). In a button, which is server side JavaScript, you can instantiate that class and write out.
You might need to handle security setting (e.g. deploying your class in a jar file into [DominoAppDir]/jvm/lib/ext) to be allowed to have network access. If you rather keep the class in the nsf, you might need harder measures.
Let us know how it goes
I just created a simple class that created the file and wrote to it. Worked like a champ
Thanks all!
I want to observe mutations of the DOM on a dynamic webpage, specifically the value of one div.I don't want to repeatedly download the webpage and search for this value, as it seems inefficient. I would like to display this value inside another program. What are my options to communicate with another program from inside a Chrome extension ?
One idea that came to my mind is this one: install a local Web server and grab POST values sent to PHP script from the Chrome extension. Then I could write to the filesystem, and observe a specific file.
Is there another way to do this ?
ok so what I am trying to do is manually handle my assets when using express. What I mean is that I do not what to have to have every stylesheet/javascript file on every page. So I wanted to be able to specify in each route whether I wanted to use another javascript file or not. Ex:
app.get('/testing',function(req,res,next){
assets.addJS('my-javascript-file');
res.render('testing');
});
So now when the template goes to render I want all of those javascript files that have been added in a local variable. I do not want to pass them on each call to render because I will want to add javascript in other places and may not necessarily need to send anything to the template which would cause me not to pass it by accident. Another thing that I want to implement is caching. I know by default it sends back the 304 not modified once it has the asset but I dont even want it making that request so I was hoping to do a query string on the files when they are output with maybe the last time they were modified and that way if I change them it will automatically tell the users browser to get the newest files but other than that it will cache them saving me bandwidth / requests (amazon s3 charges for these). If anyone can point me in the right direction or if there is already a plugin out there for this please let me know. Thanks.
You could build an asset manager around this:
app.get(function(req, res) {
res.locals.files = [ 'somefile.js', 'somefile2.js' ];
res.render('someview');
});
The view would just create multiple script files.
head
each file in files
script(src=base_url + '/' + file)
If you want to merge the files into one request you probably need to extend this even more. You could create a route that can take an array of files and merges them on each request. You can serve files with res.sendFile. This will take care of all the headers and caching if I remember correctly.