static void Mega() { MegaApiClient client = MegaNz.GetClient("*****@*****.**"); IAccountInformation info = client.GetAccountInformation(); Console.WriteLine(info.UsedQuota.ToString() + "/" + info.TotalQuota.ToString()); }
void Transfer(TransferItem item) { #if DEBUG Console.WriteLine("Transfer items:" + item.From.node.GetFullPathString()); #endif int buffer_length = 32; //default int.TryParse(AppSetting.settings.GetSettingsAsString(SettingsKey.BufferSize), out buffer_length); //get buffer_length from setting item.buffer = item.From.node.GetRoot.NodeType.Type == CloudType.Mega ? new byte[buffer_length * 2048] : new byte[buffer_length * 1024]; //create buffer ExplorerNode rootnodeto = item.To.node.GetRoot; item.byteread = 0; //this.group.items[x].UploadID = "";//resume item.SizeWasTransfer = item.OldTransfer = item.SaveSizeTransferSuccess; //resume item.ErrorMsg = ""; //clear error item.TimeStamp = CurrentMillis.Millis; if (GroupData.status != StatusTransfer.Running) { return; } switch (rootnodeto.NodeType.Type) { case CloudType.LocalDisk: #region LocalDisk ItemsTransferWork.Add(new TransferBytes(item, this)); return; #endregion case CloudType.Dropbox: #region Dropbox int chunksizedb = 25; //default 25Mb int.TryParse(AppSetting.settings.GetSettingsAsString(SettingsKey.Dropbox_ChunksSize), out chunksizedb); item.ChunkUploadSize = chunksizedb * 1024 * 1024; DropboxRequestAPIv2 DropboxClient = Dropbox.GetAPIv2(rootnodeto.NodeType.Email); if (string.IsNullOrEmpty(item.UploadID)) //create upload id { item.byteread = item.From.stream.Read(item.buffer, 0, item.buffer.Length); IDropbox_Request_UploadSessionAppend session = DropboxClient.upload_session_start(item.buffer, item.byteread); item.UploadID = session.session_id; item.SizeWasTransfer += item.byteread; } ItemsTransferWork.Add(new TransferBytes(item, this, DropboxClient)); return; #endregion case CloudType.GoogleDrive: #region GoogleDrive DriveAPIHttprequestv2 gdclient = GoogleDrive.GetAPIv2(rootnodeto.NodeType.Email); GoogleDrive.CreateFolder(item.To.node.Parent); int chunksizeGD = 5; //default int.TryParse(AppSetting.settings.GetSettingsAsString(SettingsKey.GD_ChunksSize), out chunksizeGD); item.ChunkUploadSize = chunksizeGD * 1024 * 1024; if (string.IsNullOrEmpty(item.UploadID)) //create upload id { if (string.IsNullOrEmpty(item.To.node.Parent.Info.ID)) { throw new Exception("Can't get root id."); } string parentid = item.To.node.Parent.Info.ID; string mimeType = Get_mimeType.Get_mimeType_From_FileExtension(item.To.node.GetExtension()); string jsondata = "{\"title\": \"" + item.From.node.Info.Name + "\", \"mimeType\": \"" + mimeType + "\", \"parents\": [{\"id\": \"" + parentid + "\"}]}"; item.UploadID = gdclient.Files.Insert_ResumableGetUploadID(jsondata, mimeType, item.From.node.Info.Size); } ItemsTransferWork.Add(new TransferBytes(item, this, gdclient)); return; #endregion case CloudType.Mega: #region Mega MegaApiClient MegaClient = MegaNz.GetClient(rootnodeto.NodeType.Email); item.buffer = new byte[128 * 1024]; if (string.IsNullOrEmpty(item.UploadID)) //create upload id { MegaNz.AutoCreateFolder(item.To.node.Parent); //auto create folder item.UploadID = MegaClient.RequestUrlUpload(item.From.node.Info.Size); //Make Upload url } item.From.stream = MegaApiClient.MakeEncryptStreamForUpload(item.From.stream, item.From.node.Info.Size, item.dataCryptoMega); //make encrypt stream from file ItemsTransferWork.Add(new TransferBytes(item, this, MegaClient)); return; #endregion } }