Recently I had to work on an interesting project in which the customer asked to implement file sharing over the Internet, respectively, with direct access directly from the application.
Primary requirements:
- Displays a list of files.
- Download and download through the program interface.
- Hidden authorization without user intervention.
The first thing that came to mind was to use cloud data storage with API access. So what came of it?
First problems
I decided to study the API documentation of such services as:
At first I was satisfied with all the vaults. In each, there were methods for downloading, direct downloading, deleting, displaying a list of files, as well as snippets and even a library of API interaction for NET. platforms. It seems to be all you need! But there were some critical moments for me, for example, DropBox set a limit on the number of requests to the API - 5000 per day. And the main problem of storage (in my situation): DropBox, Box, Windows Live SkyDrive in the way of authorization of client applications - OAuth. This type of authorization does not allow you to directly transfer account information to the account. Only one Ge.tt bidder remains.
')
Files for all
Ge.tt provides the user with a free 2GB storage. To interact with the cloud, you need to create an application and get
APIKey . The documentation is rather poor, but all the necessary functions are there. Terms of use fully comply with customer requirements. The authorization model is simple: POST request with
Email + Password + APIToken parameters . Bonus to this, ready dynamic library with the implementation of the necessary functions, with it we will work.
Implementation
The storage structure is defined as follows:
- Shares (Balls) - individual items (folders) containing structures.
- Files (Files) - directly structure with files.

That is, each ball can include a list of files, so you can create thematic sections corresponding to, for example, the file extension.
We describe the main algorithm:
- Authorization
- Upgrade ball.
- Getting a list of files in the balls.
- Download file.
Authorization
We connect the library to our project:
using Gett;
For security, I do not recommend to keep the username and password in its pure form, use encryption.
Get the files
As I wrote, to get a list of files, you must select a specific ball. We draw the list of the ball in listBoxShare, then when clicking on an element we will load the list of files in listBoxFiles:
user.RefreshMe();
Getting information about files is a similar process. In the SelectedIndexChanged event of the listBox_Share, we write the code:
private void listBoxShare_SelectedIndexChanged(object sender, EventArgs e) { this.listBox_Files.Items.Clear(); if (this.listBox_Share.SelectedItem is Gett.Sharing.GettShare)
It should be remembered that we get a list of files that contains:
- The number of downloads.
- Serial number.
- Full name.
- URL.
- The size.
- Date of download.
To get the necessary properties, you need to refer to the necessary element, and call the Info property:
string name= FileList[0].Info.FileName;
Now download the file. We write the code for the same SelectedIndexChanged:
if (this.listBox_Files.SelectedItem is Gett.Sharing.GettFile)
Further business of your imagination: delete, rename files, create directories. API opens wide possibilities for the implementation of any ideas. A good idea is the key to success!