nemiro-net / nemiro.oauth

Nemiro.OAuth is a class library for authorization via OAuth protocol in .NET Framework

Home Page:http://oauth.nemiro.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uploading large files

alekseynemiro opened this issue · comments

Implement the ability to upload large files.

Now available only to upload a small file size.

Uploading files is beyond the scope of the project OAuth.

The project is implemented by yourself uploading files :-) No, it's not artificial intelligence. Architecture has shown that can be opened the possibility of sending files.

Implement uploading large files a bit more complicated.

Until it is done, you can use their own methods to upload files. Use HttpWebRequest/HttpWebResponse (see for example: EpxecuteRequest) or WebClient, or HttpClient.

Small example for Dropbox:

var client = new WebClient();

// handlers
client.UploadProgressChanged += (s, ce) =>
{
  // you can create progress here
  Console.WriteLine("Uploading: {0}", ce.ProgressPercentage);
};

client.UploadFileCompleted += (s, ce) =>
{
  // exception
  if (ce.Error != null)
  {
    MessageBox.Show(ce.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    return;
  }

  // parse result
  var result = UniValue.ParseJson(Encoding.UTF8.GetString(ce.Result));
  if (result["error"].HasValue)
  {
    MessageBox.Show(result["error"].ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  }
  else
  {
    MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
  }
};

var url = new UriBuilder("https://api-content.dropbox.com/1/files_put/auto/");
url.Query = String.Format("access_token={0}", Properties.Settings.Default.AccessToken) + // your access token here
String.Format("&path=/{0}", Path.GetFileName(openFileDialog1.FileName).Replace("\\", "/")) +
String.Format("&overwrite={0}", "true") +
String.Format("&autorename={0}", "true");

client.UploadFileAsync
(
  url.Uri,
  "PUT",
  openFileDialog1.FileName, 
  null
);

Can you please update code for uploading large files...

This problem has not been solved. Today no way to upload large files using Nemiro.OAuth library. You need to write your own code to do this.

What all i need to do for uploading large file... Give me any idea sir.....!

You can use their own methods to upload files. Use HttpWebRequest/HttpWebResponse (see for example: EpxecuteRequest) or WebClient, or HttpClient.

Above is an example of code using the WebClient.

OK, I will try to fix it..