GithubHelp home page GithubHelp logo

gpailler / megaapiclient Goto Github PK

View Code? Open in Web Editor NEW
222.0 222.0 79.0 3.55 MB

MegaApiClient is a C# .Net library to access http://mega.co.nz / http://mega.nz cloud storage and file hosting service.

Home Page: https://gpailler.github.io/MegaApiClient/

License: MIT License

C# 99.89% PowerShell 0.11%
c-sharp cloud-storage mega mono myget netcore netstandard nuget uwp xamarin

megaapiclient's Introduction

Hi there πŸ‘‹

  • πŸ’¬ Ask me anything, I'm happy to help
  • πŸ“« How to reach me: [email protected]

megaapiclient's People

Contributors

croug avatar davidblkx avatar dhabierre avatar erri120 avatar federicorosso1993 avatar garsia0 avatar gpailler avatar gspp avatar igorquintaes avatar kiddailey avatar ljmf00 avatar sabihismail avatar xbenjii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

megaapiclient's Issues

Problems sending .zip file

Description:
I'm trying to send files from the .zip extension, but to no avail. The upload of the file until happens, but when I download the file again a "Decoding Error" occurs when 99% of the download arrives and Mega does not return the file. The most interesting thing is that I got the same file that I'm having problems and I sent manually by the browser and everything went well. It may be my code, but I'm not sure I can send files from other extensions without further problems.

Actual Behavior:
The upload of the .zip file happens, however at the time of download an error is displayed by the Mega: "Decoding Error"

Expected Behavior:
The .zip file will download without problems.

Steps to Reproduce:

Zipping the file and sending:

using (MemoryStream megaStream = new MemoryStream())
{
    using (ZipArchive zip = new ZipArchive(megaStream, ZipArchiveMode.Create, true))
    {
        foreach (HttpPostedFileBase upload in uploads)
        {
            ZipArchiveEntry entry = zip.CreateEntry(upload.FileName, CompressionLevel.Fastest);

            using (Stream stream = entry.Open())
            {
                upload.InputStream.CopyTo(stream);
            }
        }
    }

    /*
    Response.Buffer = true;
    Response.Clear();
    Response.ContentType = "application/zip";
    Response.AddHeader("content-disposition", "attachment; filename=Test.zip");

    Response.BinaryWrite(megaStream.ToArray());

    Response.Flush();
    */

    INode upload = await client.UploadAsync(megaStream, "Test.zip", pasta, new Progress<double>());
}

MegaApiClient Version: Latest version

Downloading File[SOLVED]

I want to download the file in the user's path. Example:
string Path = folder\somefolder\somefolder2\somefile.file This can be change and I want to download "somefile.file" help me please.

Error downloading stream

em System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
em System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
em System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
em CG.Web.MegaApiClient.MegaApiClient.SaveStream(Stream stream, String outputFile)
em CG.Web.MegaApiClient.MegaApiClient.<>c__DisplayClass54_0.b__0()
em System.Threading.Tasks.Task.InnerInvoke()

[Feature Request] Seekable Download Stream

Hi,

Very helpful Mega API implementation!

One possible addition to this is to make the download stream seekable.
Since the download url can be used with "Range" header, it's possible to make the download stream seekable.

I've done something similar for another storage service, without builtin encyption / decryption though.
Here is what I did to make the stream seekable:

https://github.com/Kimi-Arthur/Pimix/blob/master/src/Pimix.Cloud.BaiduCloud/BaiduCloudStorageClient.cs#L384-L385

https://github.com/Kimi-Arthur/Pimix/blob/master/src/Pimix.Cloud.BaiduCloud/SeekableDownloadStream.cs

Redownload of corrupt chunks

Every time a chunks checksum is not as expected the api will throw a DownloadException and therefore end the download.
I know that this behavior is perfectly fine but something quite annoying when downlaoding big files since the downlaod has to be done all over again.

I also dont know if this is even possible due to the streaming donwload, but would it be possible to create an option for just "redownloading" the last chunk if the checksumm is incorrect?

Can i check upload speed ?

is there function to check upload speed after upload ?

thanks for your help and great work hope soon .netcore supported

Shared key

Hi,

When working with shared folders, I met a a case in which the key is in this format:
"k" : "{owner1}:{key1}/{owner2}:{key2}"
So, on the Node class, we need to handle this case by getting one key:
var searializedKey = SerializedKey;
if (serializedKey.Contains("/")) {
serializedKey = serializedKey.Substring(0, serializedKey.IndexOf("/"));
}

And when retrieving shared masterkey, I think you miss this part otherwise the file attribute cannot be decrypted successfully (folder is OK):
...
if (nodesResponse.SharedKeys != null) {
...
if (this.Type == NodeType.Directory) {
DecryptedKey = masterKey;
} else if (this.Type == NodeType.File) {
DecryptedKey = Crypto.DecryptKey(encryptedKey, masterKey);
}
...

Thanks a lot for this great lib πŸ‘

Allow deserialization of node with multiple keys

Related to #8.

Some nodes contain multiple keys in SerializedKey property
// for ex: { ...,"k": "9sVHkIiY:PRb1gXULkZUiXI1xWDh46g/o5tGQTgL:Fv0FuJAbpAYTdczE7To5Mw", ...}

This can occur when a folder is shared and the parent folder is shared too.

GetAccountInformations won't work

I'm writing a programm that must check out the current space of the mega account.
I'm using MegaClientApi Version 1.2.2 (the newest one).

To get the accountinfos i'm doing this:
Dim accinfo As IAccountInformation = (Await ServerMgr.server_levels(i).GetAccountInformationAsync)

Then i try to get the this values:
Dim maxserverspace As Long = accinfo.TotalQuota
Dim curserverspace As Long = accinfo.UsedQuota

At both i get this error:
https://gyazo.com/cd53c1f60abad6a28af113f2490040e4

Few weeks ago it worked correctly.
Hope this will be fixed very soon ...

Thank you! :)

DownloadFileAsync not reporting progress.

I'm trying to download this file from a specific URL asynchronously so I can update the UI on the download, as that's what you should do. I've made some code, but whilst it does download the file without blocking the UI thread, it doesn't update any progress.

Dim clientctgp As New MegaApiClient()
clientctgp.Login("username", "password") 'My actual details are entered here
Dim progress As New Progress(Of Double)(Function(p) lblSecondary.Text = String.Format("{0}% complete", p))
clientctgp.DownloadFileAsync(New Uri("https://mega.nz/#!RvRkiYqL!Y7xb9v5Dwd_IKcFUgewnVYDPDaLmDjA8TKD6PUQaz8E"), Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & "\ctgpr.zip", progress)

It's probably me being stupid, but I'm new to the API, so I'm trying to get to grasps with it. Help would be appreciated. Thanks :)

EDIT: This code is VB.net, but i can translate c# code if needed.

The ApiClient is missing "rename" fuctionality

Description:

With the Move method, the client can move file from one place to another, but the file name cannot be changed.

Actual Behavior:

No such method provided.

Expected Behavior:

Provide a rename method or the move method accepts a third parameter as new file name.

Other notes

When we do rename on the website, it actually calls an API with action id being "a".

The API is also available as SetAttr method. See here.

Nested Folder

Hello

how could i create nested folder using ur api
something like this

Games/counterStrike/cs.rar
Games/cod/cod.rar

Exception on Login(string email, string password)

Hi, i'm testing some code and try to make a simple mega connection. he give me a exception after Login debug line.

    private const string Username = "[email protected]";
    private const string Password = "****";

    protected MegaApiClient _client;
    private MegaApiClient.AuthInfos auth;

    /// <summary>
    /// Initializes a new instance of the <see cref="FormMega"/> class.
    /// </summary>
    public FormMega()
    {
        InitializeComponent();

        Dbg.WriteLine("Mega API Client");
        _client = new MegaApiClient();

        Dbg.WriteLine("Auth");
        auth = MegaApiClient.GenerateAuthInfos(Username, Password);

        Dbg.WriteLine("Login");
        _client.Login(auth);

        Dbg.WriteLine("Nodes");
        var nodes = _client.GetNodes();
        INode root = nodes.Single(n => n.Type == NodeType.Root);
        INode myFolder = _client.CreateFolder("AlexCommands", root);
        INode myFile = _client.Upload("test.txt", myFolder);

        Dbg.WriteLine("Open URL");
        Uri downloadUrl = _client.GetDownloadLink(myFile);
        if (downloadUrl != null) Process.Start(downloadUrl.ToString());

Large file upload

I have a problem with uploading 488 Mb file.
The program simply stuck while getting request stream in method PostRequest. Smaller file (413Mb) is uploading without problems. Do anyone have encountered this issue? On the mega dev page there is written that chunked upload is also supported. Do someone know proper way of doing this?

Trailing garbage in DecryptAttributes

I encountered multiple errors in json.net with my mega account when trying to get all the nodes. It kept complaining about trailing text after the json in the Crypto.DecryptAttributes method.

There were random characters after the last '}', probably due to the AES padding.

I've fixed the issue by substringing until the first \0 character, which is probably always used as string termination character:

var json = decryptedAttributes.ToUTF8String().Substring(4);
json = json.Substring(0, json.IndexOf('\0'));

return JsonConvert.DeserializeObject<Attributes>(json);

MEGA folder "get link" issue

Oh, I didn't realize you were the maintainer here, I guess that makes sense. I figure you already know the issue then. Just having me put this here for brevity? I could copy and paste from the ShareX if you want.

[Feature Request] Make upload chunk size configurable.

Currently the upload chunk is fixed as 128KB for first 8 chunks and 1MB for all following chunks. (I don't get the logic here either)

for (int idx = 1; (idx <= 8) && (chunkStartPosition < (size - (idx * 131072))); idx++)
{
chunkStartPosition += idx * 131072;
chunks.Add(chunkStartPosition);
}
while ((chunkStartPosition + 1048576) < size)
{
chunkStartPosition += 1048576;
chunks.Add(chunkStartPosition);
}

I think it will be great if people can configure the way the chunk sizes are determined. People may want to upload by chunks of 32MB or more since small chunks may increase the effect of the HTTP / API overhead.

Thanks!

Asynchrounous Update?

Can we get support for asynchrounous downloading so we can update a GUI with the status of the download?

Upload progress for .NET 3.5

Hi!
It is possible to have upload progress with NET 3.5,I need this
I've seen there is a feature but not for 3.5

thanks!

Help with installation.

This is an issue for me, I have not used things like this before, Nodes etc. Got it to install through NuGet and have used the reference - Newtonsoft but I can't get:
MegaApiClient client = new MegaApiClient();
to work
says it's not referenced when I have referenced it. Could you show a clear installation on how to get the api working on a WinForm?

Resume Download

This is more a question/suggestion. It's possible to resume a download? If yes, how? If not i think would be a great thing to accomplish, because i can't delete incomplete files.

Error if Name of a Node is empty (INode.Name)

Hello,

I think i should post this as issue.

When a node has an empty name, then I get an error if I get the value of INode.Name.

Example:
[...].Where(Function(g) g.Type = NodeType.Directory AndAlso g.Name.StartsWith("U-"))
I want all INodes wich Type is Directory and the Name starts with "U-". But if a node hasn't a name, i get an error).

Thanks

Error at downloading file

I'm using v1.5.0 of the client.

I made a programm where I'm using this client.
A user got a error message. This message tells me an error at executing "Await MegaApiClient.DownloadAsync".

Error-Message:
https://gyazo.com/03cc2152a04e9191b3042b2cf4922fc8

This Error happens only for him, but i realy don't know why.

Would you check out, please, why this could happen?

Thanks

Public access to MegaApiClient.authInfos

Please provide public access to the field MegaApiClient.authInfos.

I'd like to retrieve the authInfos to store them externally and reload them at the start of an application to resume/renew the session without the user having to actively login.
Presently I have to resort to Reflection for retrieving the data from MegaApiClient.authInfos.

Regards
vv

[Feature Request] Account storage quota info

Could you possibly expose an API method to determine the storage quota info for the currently used MEGA account as displayed in the web interface below the menu command settings/overview or the whoami MEGA API command?
I'd be especially interested in finding out the values for total storage capacity and currently used Cloud Drive capacity - or remaining capacity, whatever is easier.

ResourceNotExists Error

whenever i try to to get Nodes after logging in i get this error

CG.Web.MegaApiClient.ApiException: API response: ResourceNotExists

wrong result url from mega upload

hi im using sharex and i was told to report the bug here because it seems to be a problem inside the api

upload a file to mega with credentials set.
it won't copy the correct url to your clipboard, when you try to download it in the browser, the progressbar will go to 100% and then it will say "decryption error".

but when i go to the file in mega after sharex has uploaded it and copy the full link manually it works.
and the link i get when copying the link also looks completely different than the one sharex got.

Retrieving file name

How do i retrieve the file name, without having to login. I want the file name of the file that I'm trying to download.

I've tried to use FileStream, but no luck.

Create folder if not exists

Hi,I try your sample code to upload a file ,it does but a new Upload folder is created every time the code runs,this is my VB code (.net 3.5):

 Dim client As New MegaApiClient
        client.Login("[email protected]", "mypass")
        Dim nodes = client.GetNodes()
        Dim root As INode = nodes.[Single](Function(n) n.Type = NodeType.Root)
        Dim myFolder As INode = client.CreateFolder("Upload", root)
        Dim myFile As INode = client.UploadFile("c:\test.zip", myFolder)
        Dim downloadUrl As Uri = client.GetDownloadLink(myFile)
        client.Logout()

thanks!

Support for uwp (.NET Core Compatibility)

When trying to download from NuGet I get the following error:

Install-Package : One or more packages are incompatible with UAP,Version=v10.0.10586 (win10-x86-aot).
At line:1 char:1
+ Install-Package MegaApiClient
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

If I understand it correctly, it is due to UWP working with NETCORE instead of .Net Framework. It would be nice if uwp was supported since it is kind of becoming more popular lately (being able to publish in store, etc...)

Slow Download/Upload

It isn't realy an issue i think, but i would ask you, if this is normal.

When I download or upload something to my MEGA Accounts via the Browser, It's realy fast (we have realy fast Internet). But when I download or upload something via your API-Client then it's realy slow often.
With your API-Client: Downloading/Uploading a little textfile or PNG takes between 10 seconds (this is realy rarely) and 60 seconds. Most it takes 30 seconds.
With the browser: Downloading/Uploading a little textfile or PNG takes one or two seconds.

I often take DownloadStream and UploadStream.

Fast download and upload would be imporant for my programm.
Simply tlease tell me, if the prblem is at your API-Client or at the MEGA-API.

I'm using the newest API-Version of you (v1.3.1).

Thanks,

Pilzinsel64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.