tidesdk open user-selected file - javascript

I'm creating a program in which the user creates projects, edits them saves them...etc. However, for opening a project, I'm stumped. I would like the user to be able to open a dialog box and select a file, then click open. Then I want to open/read that file for use in the program. Like professional softwares do. But, I don't know how to do that.

checkout the documentation for how to use Filesystem module for reading and writing files at: http://tidesdk.multipart.net/docs/user-dev/generated/#!/api/Ti.Filesystem

Related

File System Access API open file with local default application

In a web application I am working on I would like to be able to download files, modify them localy and reupload them to the server.
To make it as easy as possible for the users, I would like them to choose the download location and use a single button to upload the changes afterwards.
My current apporach is the following:
Use window.showSaveFilePicker to choose location and get a FileSystemFileHandle
Download the content and write it to the FileSystemFileHandle
Show a button which allows to upload the changes using FileSystemFileHandle#getFile to get the modified content.
This approach works pretty well but the user has to manually search and open the file after the download and I would like to support them in this step and make it as simple as possible.
Ideally the file should automatically be opened with the default application after the download but I couldn't find a way to do that.
One idea was to open the file in a new tab using the file://-URL, allowing the browser to decide what to do but the FileSystemFileHandle does not seem to expose the absoulte path.
Is there any way to open the downloaded file with the default application? If not, what other possibilities are there to make the mentioned use case as simple as possible?
Thanks in advance
EDIT:
I found that you can open certain applications using special urls like ms-excel:ofe|u|file://path/to/file.xls.
This would be enough for most use cases but for this to work I would need to get the file url from a FileSystemFileHandle.
For security reasons, there is no way for a Web app to open local apps. In the future, though, once file change events are implemented, you can await changes to the file, and then re-open it. This should solve your use case.

How to enable the download window prompt for javascript-based Selenium-webdriver?

I am using 'selenium-webdriver' npm package to simulate an endpoint user - I click on buttons, select drop-downs and checkboxes.
I come across an image that will help me download a PDF file.
So what I want and what happens when I manually click on this image button on a regular chrome tab is that it will prompt a save-window:
What actually happens is that the file is downloaded automatically in the default directory (which is 'download' folder for me), without showing the save-window prompt. If the same file is already present in the download folder, then the new file gets a suffix of "(2)" or a corresponding number to its name.
I generally use this basic Selenium documentation: https://www.selenium.dev/documentation/en/getting_started_with_webdriver/browsers/
2nd reference I use is: Selenium-javascript-docs
Most of the Selenium question-answers are in the java language, so those don't help me as I'm using the javascript package.
I do know it has to do with the chrome options, or a chrome-specific field, but the document is just lacking. I came across the chrome-driver doc, but it is not javascript-friendly.
Other than disabling the automatic-download feature, I am also interested in changing the download directory to a custom location.
Any help or reference/guide/documentation source is greatly appreciated. Thank you in advance and thank you for reading.
You can use setDownloadPath to modify the path where the file will be downloaded.
Other than that, I don't think there's an option to prevent the automatic download

Upload a file using Selenium IDE 2.9.1

Am not able to upload a file using IDE.
The application consists of a NEW FILE button, after clicking on it, it opens Windows Popup for the file in the local machine .Once the file is found in the local, it needs to be uploaded.
Please help.
The problem is manipulating the dialog window ?
You can always make use of other (free) automating tools. I recommend using AutoIt. It's free, very straight forward.

How can I let users upload files by copy/paste?

I'm trying to create a web app based on ExtJS, and I'm working on the file-upload area of the app.
I want users to be able to upload files by copying and pasting them - not just copying and pasting the contents of the file, but the file itself. For example, in Windows, you can choose "Copy" or "Cut" from the Edit menu while a file is selected, then choose "Paste" later and copy or move the file - I'd like users to be able to upload files to my app in the Paste step, by just choosing Paste in their browser.
I've already tried HTML5's drag-and-drop API, but we don't want to use that - we want users to be able to copy/cut and paste files to upload their files (as long as they're smaller than 20 megabytes). If the user copies the path to their file and pastes that directly to the page, telling us where to find the file, that could also work.
Can anyone suggest a way to do this?
The thing is, that you're not able to access the clients filesystem with javascript. There is this new Filesystem API, but this just allows you to create a virtual sandboxed filesystem. I had the same problem, thought about it a while and came up with the following ideas.
Flash
Writing a Flash bridge which access the filesystem and let the javascript communicate with it via swliveconnect
Problem: Flash doesn't have filesystem access either.
Java applet
Same thing as Flash and again with LiveConnect
In my opinion this could work, but I didn't try it out, because my goal was to get filesystem access on a chromebook. And chromeOS doesn't support Java (at least without some hacking)
ActiveX
I also found some solutions with this. I gave up at the applet part so I didn't try this out either.
As Jared Farrish said, when you copy a file the os just saves the path to the file in the clipboard. Then if you receive the paste event on your webapp just get the string out of the clipboard and forward it to your file bridge.
I've seen that DropBox.com allows this to be done (in chrome- didn't seem to work in IE). I didn't do cut and paste specifically, but dragged files into a dropbox page from a local folder, and it uploaded the files. So, this doesnt directly answer your quesiton, but perhaps you can look at how this is done in their code.

Open a save file dialog for a js variable

In my web app I need to give the user the option to save a js variable as a file (when the user clicks download, the app offers him to save a file, preffereably as .js file).
Similarly as google docs offers you to save a file.
Is it possible for javascript to pass it's variable this way?
Check out Downloadify which allows exactly this.
Downloadify is a tiny JavaScript + Flash library that enables the generation and saving of files on the fly, in the browser, without server interaction.
it requires Flash installed in the user's browser to work, though.
I know of no other way of doing this without server interaction.
You might also want to check out OpenSave:
http://www.gieson.com/Library/projects/utilities/opensave/
... which looks much like Downloadify, but seems to have a few extra features (and not as complicated?).

Categories

Resources