Download zip using jszip in Sharepoint - javascript

Hi I am looking for solutions insanely for almost 2 days.I have sharepoint library where multiple word docs uploaded.Using javascript JSZip I like to pass sharepoint file urls into it.Is this possible ?
I am getting each file server relative URL by ecmascript.Now I would like to do something like this:
function create_zip() {
debugger
var zip = new JSZip();
zip.add("http://myspsite/shareddoc/a/test.docx", "\n"); //this is hardcoded for testing??here I have file url
//zip.add("hello2.txt", "Hello Second World\n");
content = zip.generate();
location.href = "data:application/zip;base64," + content;
}
Any pointers or how I proceed from here?
Thanxs.

It´s insanely but interesting. Could works. Creating a button and calling the library and the script, I´m sure of that.
or, try this: http://techtrainingnotes.blogspot.com.ar/2010/05/sharepoint-2010-windows-explorer-view.html
This is more simple.

Related

Creating Photoshop Plugin - trying to find simpler way to source file in javascript function

I'm creating a plugin I would like to be used for both Mac and Windows.
As the file trees are different, I would like to find a simpler way to source a file in a function contained in my /host/index.jsx file.
My file is located at /files/thisismyfile.psd
Currently I can only successfully source it by entering the full file tree from the main hard drive:
var fileRef = new File("/Library/Application Support/Adobe/CEP/extensions/com.my.panel/files/thisismyfile.psd");
I would much prefer to use something like:
var fileRef = new File("./files/thisismyfile.psd");
I've also tried testing having the file in each other folder and simply searching for:
var fileRef = new File("thisismyfile.psd");
With no luck! Any ideas?
Failing that, is it possible to code it so that it says:
"If this is mac, then search for the file here. If this is windows, then search for the file here."?
I ended up using this script to determine the location of the file depending on whether the system being used is mac or windows.
function isMacOS() {
return ($.os.toLowerCase().indexOf('mac') >= 0);
}
var fileRef = isMacOS()
? new File("/Library/Application Support/Adobe/CEP/extensions/my.panel/files/filename.psd")
: new File("C:\Program Files\Common Files\Adobe\CEP\extensions\my.panel\files\filename.psd");
var docRef = app.open(fileRef);
};

set file attribute filesystemobject javascript

I have created a file as part of a script on a network drive and i am trying to make it hidden so that if the script is run again it should be able to see the file and act on the information contained within it but i am having trouble doing this. what i have so far is:
function doesRegisterExist(oFs, Date, newFolder) {
dbEcho("doesRegisterExist() triggered");
sExpectedRegisterFile = newFolder+"\\Register.txt"
if(oFs.FileExists(sExpectedRegisterFile)==false){
newFile = oFs.OpenTextFile(sExpectedRegisterFile,8,true)
newFile.close()
newReg = oFs.GetFile(sExpectedRegisterFile)
dbEcho(newReg.Attributes)
newReg.Attributes = newReg.Attributes+2
}
}
Windows Script Host does not actually produce an error here and the script runs throgh to competion. the only guides i have found online i have been attempting to translate from VBscript with limited success.
variables passed to this function are roughly declared as such
var oFs = new ActiveXObject("Scripting.FileSystemObject")
var Date = "29-12-2017"
var newFolder = "\\\\File-Server\\path\\to\\folder"
I know ActiveX is a dirty word to a lot of people and i should be shot for even thinking about using it but it really is a perfect fit for what i am trying to do.
Please help.
sExpectedRegisterFolder resolves to \\\\File-Server\\path\\to\\folder\\Register which is a folder and not a file.
I get an Error: file not found when I wrap the code into a try/catch block.
I tested the code on a text file as well, and there it works.
So you're either using the wrong method if you want to set the folder to hidden.
Or you forgot to include the path to the text if you want to change a file to hidden.
( Edit: Or if Register is the name of the file, add the filetype .txt ? )
If you change GetFile to GetFolder as described in https://msdn.microsoft.com/en-us/library/6tkce7xa(v=vs.84).aspx
the folder will get hidden correctly.

Get / Read Text File from URL - Javascript for After Effects

I'm used to selecting, opening and reading a text file (CSV, JSON) from my local directory. I now have access to our data feeds online but don't know how to do the same thing with a URL instead of a local file.
For a local file I simply use something like this:
var myFile = File.openDialog();
myFile.open();
myFile.read();
Is there a way to do this with a feed from a URL in javascript for AE?
Here is one of the feeds: feeds.nfl.com/feeds-rs/schedules.json
No need to save file, just one line do the trick =)
data = JSON.parse(system.callSystem('curl -s "https://path_to_json"'));
I think in After Effects the easiest way is to do a system call.
The Socket object from ExtendScript is complicated. Look at GetURLs.jsx by Rorohiko.
You need to allow your script to access the network. See this stackoverflow
# Mac Osx
var curlcmd = "curl feeds.nfl.com/feeds-rs/schedules.json > ~/Desktop/test/schedules.json";
var stdout = system.callSystem(curlcmd);
$.writeln(stdout);
var file = File("~/Desktop/test/schedules.json");
file.open();
var content = file.read();
file.close();
$.writeln(content);

node-webkit using window.open() to download a file open another window

I'm currently porting a nodejs / angular webapp to Windows using nodewebkit. Everything has been working pretty well for now but I'm facing a litle problem when I want the user to download a file.
In order to start the download with the save file Dialog, I use a simple window.open(url) where url can be a link to any kind of files. This line actually do it's job and pop the window dialog for saving a file, but at the same time, a blank node-webkit page appears.
I've been trying to mess around with node-webkit for a while without managing to remove this blank page.
As anyone experienced the same kind of behavior ?
I'll be interested in any lead, I'm not into the js stuff for long so I may have missed something obviouvs.
Have a nice wathever time of the day it is where you live !
a more better solution is found here
Step 1 In your html file, add a Input tag block like below:
<input id="export_file" type="file" nwsaveas style="display:none" nwworkingdir=""/>
Step 2 Add a new function in your javascript file like below:
function saveFile(name,data) {
var chooser = document.querySelector(name);
chooser.addEventListener("change", function(evt) {
console.log(this.value); // get your file name
var fs = require('fs');// save it now
fs.writeFile(this.value, data, function(err) {
if(err) {
alert("error"+err);
}
});
}, false);
chooser.click();
}
Step 3 Save your file where ever you like by using saveFile(name,data) function like below:
...
_exportCSV="you data to save";
saveFile('#export_file',_exportCSV);
...
As questioner said to be working:
location.href = url
Is the correct usage.

Cannot find file in the gallerie after downloading it with PhoneGap in Android

i have a problem with the the downloaded files in my PhoneGap-App for Android.
The download-Function from PhoneGap actually works quite well i think. It gets the file from the URL and
stores it on the SD-Card. (Code is below)
So where is the Problem? When I download a JPG or PNG to the
Download-folder, i want it be accessible through the native Gallery.
But the picture don´t appear in the gallerie. To see it I have to
restart the phone or I have to use another App like Astro.
Is there a "Refresh_the_native_Gallerie"-Function or something like that?
Thank you very much.
try {
var filePath = 'file:///mnt/sdcard/Download/google.png'; // Correct filePath
var url = "https://www.google.de/images/srpr/logo3w.png"; //Correct URL
var fileTransfer = new FileTransfer();
fileTransfer.download(url, filePath, function(entry) {
console.log("s3_download download complete: " + entry.
// Do i need a "Refresh_all_other_Apps"-function here?
}, function(error) {
// Normally no Error
console.log("s3_download download error source " + error.source);
console.log("s3_download download error target " + error.target);
console.log("s3_download download error code" + error.code);
});
} catch (e) {
console.log("downloadTest ERROR: " + e);
}
Cannot answer my own question so fast only edit my question. So here is the answer:
I wrote a little PhoneGap-Plugin, which does actually nothing more than calling the code from zapl. Thanks again. Hope it will help someone with the same problem.
You can find the code here: https://github.com/philipp-at-greenqloud/pluginRefreshMedia
I don't know if that helps you in PhoneGap / JavaScript context:
Your problem is that the gallery will only display files that are indexed in the device media-database. Just adding a file to the file system will not automatically add it to that database. And pretty much the only time a rescan / update of that database happens is when you reboot the device or remount the sdcard (after it was shared with a PC or in case you ejected it and put it back in).
To have a file added to the database the simplest way to to that is to send Intent#ACTION_MEDIA_SCANNER_SCAN_FILE to the MediaScanner to let it add your file to the database. Once that is done the file will show up in the gallery.
Java code for that would be
File newImage = new File("/mnt/sdcard/Download/google.png");
Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
scanIntent.setData(Uri.fromFile(newImage));
sendBroadcast(scanIntent);
I wrote a little PhoneGap-Plugin, which does actually nothing more than calling the code from zapl. Thanks again.
Hope it will help someone with the same problem.
You can find the code here: https://github.com/philipp-at-greenqloud/pluginRefreshMedia
This is a well needed plugin. I have been trying to do work arounds for this issue and the plugin works a treat. I was looking at developing one myself, but you have done a great job. My headaches are now subsiding. This works for me.

Categories

Resources