Box.net URL Schemes - box-api

I'm writing an iPhone app, MyApp, which needs access to documents on and off-line. My users are already managing these documents (pdf's, movies, etc) via the Box iPhone app synching with the company server.
If MyApp knows the path & filename of a document, is it possible to use the Box URL Schemes to launch Box and open the document externally?
MyApp doesn't need to store or access the files and since Box already has the files downloaded, there's no point storing them in the Document space of both apps.
If there is such a URL Scheme, two follow up questions are: A) is there a callback to return to MyApp when the document is closed, and B) can MyApp use another URL Scheme to get a list of documents?
NSURL *ourURL = [NSURL URLWithString:#"box://some/path/to/fileid?callback=myapp://"];
if ([ourApplication canOpenURL:ourURL]) {
[ourApplication openURL:ourURL];
}
If this isn't currently possible, but of interest to Box, I'm interested in being a beta tester/early adopter.

If you just want to direct the user to a Box page, you may be able to direct the user to a specific file in one of two ways:
1) If the file is shared in Box and you have the shared name, you can generate a shared url (see sharing in the docs at developers.box.com). This only works for files that were shared, however.
2) If you have the file id of the file in Box, you can generate a URL to which the user can login to one's Box account and view the content. You can determine that URL by going into Box and seeing how URLs are displayed when you click on a particular file. We don't like to advertise that URL for developers, however, because we don't guarantee that this URL format will be maintained in the future. It hasn't changed in a while, so it's probably safe to use, but Box provides that "use it at your own risk" disclaimer.
Unfortunately, Box doesn't have a way to pull up a file based on file path. You need the file id or shared name. There isn't a url that relies on file or folder names.

Related

Access publicly shared OneDrive folder via API

I have a publicly shared OneDrive folder with some various sub-folders and files. I.e. I have shared it via a link, so anyone with this link can access them.
Is there a way I can access these files from either client-side JavaScript or some server-side code via a REST API of some sort? Without having to use any sort of user-specific credentials?
What I've been trying
I've been looking at the Accessing Shared Content page, and it looks like what I want, but can't figure out how to use it.
I've taken something that looks like an id from the shared URL, which looks to be a long hexadecimal number (which seems to be an id pointing at me?), an !, and then a number (which I assume has to do with the shared resource).
I've then tried to stick it in this URL:
https://api.onedrive.com/v1.0/shares/<id>/root?expand=children
But I get back a 400 Bad Request, so something isn't quite right...
I'm thinking maybe some sort of authentication is missing, but since the shared files are public, I don't users to have to login with their credentials, and can't of course use my own in code.
I've tried to register an app, where I get an application id (guid) and can generate Passwords and Key-Pairs. Was hoping maybe I could use that, but don't see in the API how and where to actually use those...
Goal
The shared folder contains sheet music for a choir, that I'm responsible for keeping updated (and OneDrive syncing is super handy here).
Some members aren't very computer savvy, so I'd like to make seeing and downloading these files as easy as possible. The shared link with a "go here to this other strange site and find the files there"-text sort of works, but I would much rather like to list the files directly in a member-only area of our website. Basically just "here are the files, click on one to download it".
Yes, you can use the REST API to access the contents of a folder.
The API is the one you mentioned, the shares API. However, it sounds like you are perhaps using the wrong ID.
The most straightforward way to do this is to follow the instructions to encode the actual sharing URL into a token. This way you create a base64 encoded version of the sharing link, append a "u!" to the front of that string, and then make the exact call you already mentioned. You'll get back a list of the files in the shared folder and you can go from there.
Here's an example of this:
Here's a sharing link to a folder in OneDrive with some photos in it.
https://1drv.ms/f/s!AtuAM_NacwVahiFpuMGS_BiQCwWu
To convert this URL into the API, you first base64 encode the URL and append u!
u!aHR0cHM6Ly8xZHJ2Lm1zL2YvcyFBdHVBTV9OYWN3VmFoaUZwdU1HU19CaVFDd1d1
Now you can use this URL as the sharing token, and expand children and thumbnails:
https://api.onedrive.com/v1.0/shares/u!aHR0cHM6Ly8xZHJ2Lm1zL2YvcyFBdHVBTV9OYWN3VmFoaUZwdU1HU19CaVFDd1d1/root?expand=children
Clicking on this bottom link should give you the JSON response, which includes the shared folder and the children inside the folder.

Chrome App: Getting a list of files in a designated folder

I am building a chrome app for Digital Signage where I need the user to select some files from a particular folder (preferably in the app's directory) i.e audio, videos, photos which should be created by the app on install.
The sample code provided by Google requires that the user navigates to a folder like this
chrome.fileSystem.chooseEntry({type: 'openDirectory'}, function(theEntry) {
if (!theEntry) {
output.textContent = 'No Directory selected.';
return;
}
// use local storage to retain access to this file
chrome.storage.local.set({'chosenFile': chrome.fileSystem.retainEntry(theEntry)});
loadDirEntry(theEntry);
});
However, my app simply needs the name of files in that (say Video) known directory for the user to build a playlist, rather than actually selecting a video file.
Is this supported in chrome.fileSystem API? Any pointers to how I cold get this done?
It sounds like you should be using either the app's sandboxed file systems, or the app's install folder itself.
The sandboxed file systems allow the app to store whatever data it wants, in whatever structure it wants. There are two to choose from: persistent or temporary. Temporary may be cleared at any point in time. To use these check out this article. Some of its code may be out of date with the spec. Note also apps need to request the unlimitedStorage to use these.
The install folder itself can be used in a read only way. To do this you use chrome.runtime.getPackageDirectoryEntry.

WinJS - How to access whole folder tree without FolderPicker

I'm building a Store App using WinJS and I need to create a structure with some info related the user's tree folder (every drive, not only C:), is there any way to get the whole Folder structure from every drive without using the File/FolderPicker?
No, by design Windows Store Apps run inside an app container that limits what they're allowed to do without user consent. The only areas of storage that are openly accessible without further consent are the app's package location (which is read-only, see [Windows.ApplicationModel.Package.Current.installedLocation][1]) and its app data folders (see Windows.Storage.ApplicationData).
If the app declares library access in its manifest (for Pictures, Videos, and Music), these are noted on the app's page in the Store such that the act of installing the app amounts to user consent. There is also a RemovableStorage library that's similar, but for that you have to declare specific file types.
If an app is registered for a file type association in its manifest, and the user launches the app through a file, that grants access.
Beyond this, the way you get access to any other storage location is through the pickers. However, if you have the user pick once, you can save that consent by saving the StorageFolder into the Windows.Storage.AccessCache API, so that you can open the folder again in an future app session without having to reacquire consent.
For all the details of this, refer to the first section of Chapter 11, "The Story of State, Part 2: User Data," of my free ebook, Programming Windows Store Apps with HTML, CSS, and JavaScript, Second Edition.

Choosing a File Path as Part of a HTML form

I'm developing an intranet site for my company, and part of the task it has to perform is to hold a database of files and their locations as submitted by users (the files are on a network drive and people viewing the database can click links to the files to access them). I have it working now using a standard text input field where the user enters the path to the file, but is there a way of giving the user a Browse... button to choose the path instead?
Using the type="file" option isn't suitable as I don't want the actual file submitted, and it only gives the filename, not the path for security reasons. But that's the sort of thing I'd like.
Thanks!
No.
Browsers aren't designed to expose details of the client file system to the server.
Build your file browser server side instead. The server should be able to access the same network drive.

How to save a local file programmatically given an amount of data and a file name with html5

I want to implement this use case found on the W3C File API document:
User agents should provide the ability to save a local file programmatically given an amount of data and a file name.
Example: A Spreadsheet App. User interacts with a form, and generates some input. The form then generates a CSV (Comma Separated Variables) output for the user to import into a spreadsheet, and uses "Save...". The generated output can also be directly integrated into a web-based spreadsheet, and uploaded asynchronously.
Source: http://www.w3.org/TR/file-upload/#requirements
From my understanding, it should be possible to create a completely offline Spreadsheet app with this, but I could not find a single example both in the W3C document or on the web that has this kind of use case implemented. At least not a completely offline one. Of course it doesn't need to be a spreadsheet application; a simple text editor or TODO manager would suffice. Am I missing something?
Also, would this make it possible to create one of the previously mentioned applications (text editor, todo manager or even spreadsheet app) from a single html5 file (with embedded JS and css)?
I seems I didn't search hard enough, here's an example of what I want http://html5-demos.appspot.com/static/a.download.html