Skip to content

Commit

Permalink
command-line key for changing user-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
yar229 committed Nov 26, 2016
2 parents 99a45d4 + e8b17cc commit c8907fd
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 23 deletions.
4 changes: 4 additions & 0 deletions WDMRC.Console/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ class CommandLineOptions
[Option("maxthreads", Default = 5, HelpText = "Maximum concurrent connections to cloud.mail.ru")]
public int MaxThreadCount { get; set; }

[Option("user-agent", HelpText = "\"browser\" user-agent")]
public string UserAgent { get; set; }


}
}
3 changes: 1 addition & 2 deletions WDMRC.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Threading.Tasks;
using CommandLine;
using NWebDav.Server;
using NWebDav.Server.Handlers;
using NWebDav.Server.Http;
using NWebDav.Server.HttpListener;
using NWebDav.Server.Logging;
Expand Down Expand Up @@ -85,7 +84,7 @@ private static async void DispatchHttpRequestsAsync(HttpListener httpListener, C
var requestHandlerFactory = new RequestHandlerFactory();

// Create WebDAV dispatcher
var homeFolder = new MailruStore(true);
var homeFolder = new MailruStore();
var webDavDispatcher = new WebDavDispatcher(homeFolder, requestHandlerFactory);

// Determine the WebDAV username/password for authorization
Expand Down
21 changes: 5 additions & 16 deletions WebDavMailRuCloudStore/Cloud.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.SessionState;
using MailRuCloudApi;
using File = MailRuCloudApi.File;
using MailRuCloudApi;

namespace WebDavMailRuCloudStore
{
Expand All @@ -17,17 +9,14 @@ static Cloud()

}

public static void Init(string login, string password)
public static void Init(string login, string password, string userAgent = "")
{
if (!string.IsNullOrEmpty(userAgent))
ConstSettings.UserAgent = userAgent;

Instance = new MailRuCloud(login, password);
}

//public static async Task<Stream> GetFileStream(File file, bool includeProgressEvent = true)
//{
// var stream = await _cloud.GetFileStream(file, includeProgressEvent);
// return z;
//}

public static MailRuCloud Instance;

}
Expand Down
2 changes: 1 addition & 1 deletion WebDavMailRuCloudStore/MailruStoreItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public async Task<DavStatusCode> UploadFromStreamAsync(IHttpContext httpContext,
try
{
// Copy the information to the destination stream
using (var outputStream = IsWritable ? Cloud.Instance.GetUploadStream(Name, _fileInfo.FullPath, ".bin", _fileInfo.Size.DefaultValue) : null) //GetWritableStream(httpContext))
using (var outputStream = IsWritable ? Cloud.Instance.GetUploadStream(_fileInfo.FullPath, ".bin", _fileInfo.Size.DefaultValue) : null) //GetWritableStream(httpContext))
{
await inputStream.CopyToAsync(outputStream).ConfigureAwait(false);
}
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
-l, --login Required. Login to Mail.ru Cloud
-s, --password Required. Password to Mail.ru Cloud
--maxthreads (Default: 5) Maximum concurrent connections to cloud.mail.ru
--user-agent "browser" user-agent
--help Display this help screen.
--version Display version information.
```
Expand All @@ -36,6 +37,5 @@ Bad news: Total Commander [WebDAV plugin](http://www.ghisler.com/plugins.htm) do


**Remarks**
* Do not use #, %, + and ? in file and folder names

Contact me [@telegram](https://telegram.me/joinchat/AMLaOUEV8iINKKU2WBH1sw)
* Avoid using #, %, + in file and folder names
* If you have paid account - you can remove 2Gb file limitation using --user-agent "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17/TCWFX(x64)" (taken from [pozitronik/CloudMailRu]( https://github.com/pozitronik/CloudMailRu), no any guarantees, speed limits may exits)

0 comments on commit c8907fd

Please sign in to comment.