3

I am looking for a way to read files from all the various cloud storage systems out there without writing code for each specific API. Is there a way to accomplish this? What we need is pretty simple:

  1. A way to get folder contents for a FileOpen dialog box.
  2. A way to read the selected file.
  3. Optional: a FileOpen dialog that does all the work to show the files and select one.

thanks - dave

David Thielen
  • 28,723
  • 34
  • 119
  • 193
  • "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Luigi Nov 10 '14 at 18:03
  • Ok, re-written listing the specific need. – David Thielen Nov 10 '14 at 22:25
  • What you need is _not_ pretty simple, you're asking for a virtual filesystem (unless you want to download all files to local first, which I suposse you don't). See [Windows virtual disk for remote web service](http://stackoverflow.com/questions/8151813/), [Dropbox and its “Folder” like design](http://stackoverflow.com/questions/13640599/), [Writing a user mode filesystem for windows?](http://stackoverflow.com/questions/1412763/). Once you've got that figured out, consuming multiple web services and showing their contents as a local filesystem and reading files from them is trivial. – CodeCaster Nov 10 '14 at 22:31
  • @CodeCaster I agree it's not simple. That's why I'm asking if anyone is aware of some means to get this info without writing code specific to every API. – David Thielen Nov 10 '14 at 22:38
  • And I'm saying the problem is not the different APIs (and no, there's no library that I know of that combines those, so you'll have to at least write those parts yourself), but [the problem is showing the web services' contents (i.e. non-local files) in an OpenFileDialog](http://stackoverflow.com/questions/10574272/c-sharp-open-savefiledialog-with-a-different-file-system). :) – CodeCaster Nov 10 '14 at 22:40
  • 2
    Check out [kloudless.com](https://kloudless.com) (co-founder here). Kloudless provides a single REST API to over 20 different cloud storage providers, including Dropbox, OneDrive, Google Drive, and Box. You can certainly use our API from C# to list folder contents as shown [here](https://github.com/vinodc/kloudless-c-sharp-demo/blob/master/KloudlessDemo/Account.cs#L46). Docs here: https://developers.kloudless.com/docs/latest#folders-retrieve-folder-contents – vinod Dec 10 '15 at 07:57

2 Answers2

2

There is a solution to this problem. point.io has a public api that brokers access to cloud & enterprise storage providers via restful api. It basically has the functionality you're looking for. The api enables developers to view the various storage providers as types and does all the heavy lifting for your app.

They have a github repo that has C# src code examples

Here is some simple C# code that calls a file list:

public async Task<List<FolderContent>> list(String sessionKey, String shareid, String containerid, String path)
{
HttpClient tClient = new HttpClient();
tClient.DefaultRequestHeaders.Add("AUTHORIZATION", sessionKey);
var query = HttpUtility.ParseQueryString(string.Empty);
query["folderid"] = shareid;
query["containerid"] = containerid;
query["path"] = path;
string queryString = query.ToString();
var rTask = await tClient.GetAsync(PointIODemo.MvcApplication.APIUrl + "folders/list.json?" + queryString);
var rContent = rTask.Content.ReadAsStringAsync().Result;
var oResponse = JsonConvert.DeserializeObject<dynamic>(rContent);
if (oResponse["ERROR"] == "1")
{
HttpContext.Current.Response.Redirect("/Home/ErrorTemplate/?errorMessage=" + oResponse["MESSAGE"]);
}
var rawColList = JsonConvert.DeserializeObject<List<dynamic>>(JsonConvert.SerializeObject(oResponse["RESULT"]["COLUMNS"]));
var rawContentList = JsonConvert.DeserializeObject<List<dynamic>>(JsonConvert.SerializeObject(oResponse["RESULT"]["DATA"]));
var fContentList = new List<FolderContent>();
foreach (var item in rawContentList)
{
FolderContent tContent = new FolderContent();
tContent.fileid = item[MvcApplication.getColNum("FILEID", rawColList)];
tContent.filename = item[MvcApplication.getColNum("NAME", rawColList)];
tContent.containerid = item[MvcApplication.getColNum("CONTAINERID", rawColList)];
tContent.remotepath = item[MvcApplication.getColNum("PATH", rawColList)];
tContent.type = item[MvcApplication.getColNum("TYPE", rawColList)];
tContent.size = item[MvcApplication.getColNum("SIZE", rawColList)];
tContent.modified = item[MvcApplication.getColNum("MODIFIED", rawColList)];
fContentList.Add(tContent);
}
return fContentList;
}
punkdata
  • 885
  • 8
  • 15
-1

you can use "API v1 (Core API)" for : A way to get folder contents for a FileOpen dialog box. A way to read the selected file. Optional: a FileOpen dialog that does all the work to show the files and select one.

take simple example : Get list of files and folders from your dropbox account

      //get the files from dropbox account and add it to listbox

   private void GetFiles()
    {
        OAuthUtility.GetAsync
        (
        "https://api.dropboxapi.com/1/metadata/auto/",
            new HttpParameterCollection
            {
               { "path", this.CurrentPath },
               { "access_token", Properties.Settings.Default.AccessToken }
            },
            callback : GetFiles_Results
        );
    }


  private void GetFiles_Results(RequestResult result)
    {
        if(this.InvokeRequired)
        { 
        this.Invoke(new Action<RequestResult>(GetFiles_Results), result);
        return;
        }

        if (result.StatusCode == 200) //200 OK- Success Codes
        {
            listBox1.Items.Clear();

            listBox1.DisplayMember = "path";

            foreach (UniValue file in result["contents"])
            {
                listBox1.Items.Add(file);

            }

            if(this.CurrentPath != "/")
            {
                listBox1.Items.Insert(0,UniValue.ParseJson("{path: '..'}"));
            }
        }
        else
        {
            MessageBox.Show("Failed to add file to listbox");
        }
    }
Deepak Pote
  • 125
  • 2
  • 6
  • This seems to answer the question specifically for Dropbox, but the OP asked for a way to access "all the various cloud storage systems out there without writing code for each specific API" -- this is just a specific implementation for a single cloud storage system. – mejdev Dec 10 '15 at 17:22
  • Then it is not possible to access all the various cloud storage systems without writing code for each specific API..... – Deepak Pote Dec 11 '15 at 09:07
  • You must use specific API - To get folder contents for a FileOpen dialog box. - A way to read the selected file. - FileOpen dialog that does all the work to show the files and select one. – Deepak Pote Dec 11 '15 at 09:08
  • But one option for you is...access local storage of dropbox....Where the dropbox is installed.... – Deepak Pote Dec 11 '15 at 09:10