-
-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Description
Description:
Works fine when you run from visual studio (Release/Debug) mode, but when you try to call Mega function after published with AoT profile just fails
what are you trying to do
*Snippet from code
using CG.Web.MegaApiClient;
public static void UploadToMegaWithProgress(string zipFilePath, int mode)
{
string zipFileName = Path.GetFileName(zipFilePath);
string uploadDirectoryName = mode == 0 ? memoryDumpDirectory : crashReportDirectory;
MegaApiClient client = new MegaApiClient();
client.Login(megaEmail, megaPassword);
INode root = client.GetNodes().Single(n => n.Type == NodeType.Root);
INode uploadDirectory = EnsureDirectoryExists(client, root, uploadDirectoryName);
using (var fileStream = new FileStream(zipFilePath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 32 * 1024))
{
long totalBytes = fileStream.Length;
long uploadedBytes = 0;
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
int lastUpdate = 0;
int progressLinesStart = Console.CursorTop;
bool uploadComplete = false;
client.UploadAsync(fileStream, zipFileName, uploadDirectory, null, null, CancellationToken.None).Wait();
uploadedBytes = fileStream.Length;
double percentage = Math.Min((double)uploadedBytes / totalBytes * 100, 100);
double speed = uploadedBytes / stopwatch.Elapsed.TotalSeconds;
TimeSpan timeElapsed = stopwatch.Elapsed;
double timeLeftSeconds = (totalBytes - uploadedBytes) / speed;
TimeSpan timeLeft = TimeSpan.FromSeconds(timeLeftSeconds);
string timeElapsedFormatted = string.Format("{0:D2}:{1:D2}:{2:D2}", timeElapsed.Hours, timeElapsed.Minutes, timeElapsed.Seconds);
string timeLeftFormatted = string.Format("{0:D2}:{1:D2}:{2:D2}", timeLeft.Hours, timeLeft.Minutes, timeLeft.Seconds);
string progressBar = GenerateProgressBar(percentage, 25);
string formattedSpeed = FormatBytes(speed) + "/s";
string formattedUploaded = FormatBytes(uploadedBytes);
string formattedTotal = FormatBytes(totalBytes);
string secondLine = $"[{progressBar}] {percentage:F2}%";
string thirdLine = $"{formattedUploaded} / {formattedTotal} - {formattedSpeed}";
string fourthLine = $"Time Elapsed: {timeElapsedFormatted} - Time Left: {timeLeftFormatted}";
Console.SetCursorPosition(0, progressLinesStart + 1);
Console.Write(secondLine.PadRight(Console.WindowWidth));
Console.SetCursorPosition(0, progressLinesStart + 2);
Console.Write(thirdLine.PadRight(Console.WindowWidth));
Console.SetCursorPosition(0, progressLinesStart + 3);
Console.Write(fourthLine.PadRight(Console.WindowWidth));
if (uploadedBytes == totalBytes && !uploadComplete)
{
uploadComplete = true;
fileStream.Close();
Console.WriteLine();
if (File.Exists(zipFilePath))
{
File.Delete(zipFilePath);
Console.WriteLine($"File {zipFileName} deleted successfully.");
}
Messages.DumpCompleted(zipFileName);
}
stopwatch.Stop();
}
client.Logout();
}
MegaApiClient Version:
Lasted
Metadata
Metadata
Assignees
Labels
No labels