HTML5 FS API: Let the user create files outside of the sandbox? - javascript

Is there a way to create a file outside of the sandbox? Maybe something that works by first storing the file inside the sandbox and then letting the user drag a link to the locally stored file into a regular folder?
It is for a webchat: I want the user to be able to receive files, but I can't figure out a way that ensures that he can choose the target location that doesn't need a right-click->save as. If there is a better solution than using the filesystem API, feel free to suggest that, too.

How about an "a" element with a download attribute, and using FileEntry.toURL() to populate the href target?

Use a signed java applet to get root access to the system

Related

Using Azure's azcopy tool from within a javascript azure function

My setup is the following: I have 1 storage account with a container and I have another storage account with a different container. What I want to do is have a blob trigger activate whenever someone uploads a file to the first storage account, and have that blob be copied to the second storage account's container. azcopy works well with the command line, but I have not found a way to use it within an azure function. Any help is appreciated, thanks.
For NodeJS, you would just use Child Processes (or a wrapper like execa) to run executables but isn't something I would recommend you do. Also, when running on Azure, you will have to make sure azcopy is present and if you still need to go down this path, Custom Containers would be your best bet.
In the case of Azure Functions if the file just must be copied to a different container, you could just use the Blob Output Binding which would achieve this with almost no code.
For more complex scenarios where the output binding lacks, you could just use the Blob Storage NodeJS SDK directly in your code.

Is there any way to see an uploaded document into my react app?

Hi onto my react app I need to see a document but I cannot upload it manually. I'll explain, the user if need, could upload a document and into another part of the app could see it.
I want to know if there's a possibility to organize something like
See document
So the user onClick can see the doc opened in another tab. I do some logic but I upload the document on my store after he can see it in the review mode.
So can I visualize it without charging it on localStorage or sessionStorage, should I use an external library?
It depends on the format of the document. if it's an image you can show it by encoding it to base64 for other types of documents I'm afraid you have to have it stored at some URL.
You don't need to upload it anywhere to open it, after the 'upload' (using the file chooser) you can store it in a variable and use it as you please (keep in mind that this is not always a good approach). However if you want to visualize\open it in the application, it depends on the file format and you might need to use an external library to interpret and present it
edit: add note in parenthesis

Best way to get a file's path and paste it in a text file

I am trying to write a program, or HTML page actually, with 3 inputs, Firstname, Lastname, and Date, and a OK button. It should look for the file with those three inputs as a file name (ie.: John_Smith_22AUG13.pdf) inside of an specific folder (ie. C:\Test\John_Smith_22AUG13.pdf) and if it exists copy the path to the clipboard so the user can then paste it in an email.
I was wondering if someone has done something similar in the past and has any advice or programming language I should use to do this.
Can this be done using javascript? If not what else could I use?
Anything helps! Thanks!
I could be mistaken, but as this is within a webpage I believe you can't get direct access to the file system of the users computer. This would open a number of security holes, and that would be bad. So from within a webapp, I don't believe that this is possible.
You can take a look at http://www.w3.org/TR/FileAPI/#dfn-filelist and try out the
<input type="file">
kind of way and handle the chosen file in a JS method. As brandon-gardiner already said, the access to the local filesystem is actually very limited due to security restrictions
If you meant a file stored on your local computer, you will have to create a program using languages like C, C++, or maybe even PHP if you create a local webserver. Accessing files on your computer just using a html or JavaScript is not possible.
As your question is not quite clear, maybe a file input is what you are looking for, like Jeroen answered. Then you can maybe use JavaScript to determine the path of the selected file... Although, as you said you were good in JavaScript, you probably already known that.

Phonegap Use Intent / WebIntent to pick file

Please I am looking to use intent/webintent to open an app that can be used as a file browser/explorer for selecting audio files.
The URL(fullpath) for selected item would then be passed as source for in app media.play().
Any samples would be welcome.
Thanks.
Ismael.
You might check my plugin for Phonegap, which as I believe can do what you need.
https://github.com/markeeftb/FileOpener
All you gotta do is to pass a variable with the local path of the file:
window.plugins.fileOpener.open("file:///mnt.sdcard/Android/data/com.example.app")
You would only need to correct FileOpener.java file, so it matches file types you want to handle, for example mp3, wav etc.

How to load file contents from another domain using just JS?

I'm thinking of doing some online file manipulation for mobile users, the idea being that the user provides a URL to the file, then the file contents are modified by the JS, and can then be downloaded. But I haven't been able to figure out how to get the file when it's on a separate domain using just JS.
Is this possible? If so any hints or examples would be appreciated.
Just wanted to add that part of what I wanted to do was make it available without my hosting it. I'm thinking of something like a a file they can host somewhere,and then all of the bandwidth is their own...and that of wherever they are getting the file from of course.
The only way to load contents of a file on another domain is from within a <script> tag. This is how JSONP works. Look into getting your target file into this format.
The other way would be to use a local proxy. Create a web service method that loads and returns the contents of the file, then call that locally using your favorite JavaScript framework.
Depending on how you think of public webservices, and within some limitations I'm still mapping, you can do this using an ajax call to YQL, like so.
(will expand the answer later).
http://query.yahooapis.com/v1/public/yql?q=select%20%2a%20from%20data.uri%20where%20url=%22http://t3.gstatic.com/images?q=tbn:ANd9GcSyART8OudfFJQ5oBplmhZ6HIIlougzPgwQ9qcgknK8_tivdW0EOg%22
One of the limitations of this method is file size, it currently tops out at 25k.

Categories