Ejemplo n.º 1
0
        private void CloudImport_Click(object sender, RoutedEventArgs e)
        {
            string Token, AccountId;

            if (StoredToken != null && StoredAccountId != null && VerifyToken())
            {
                Token     = StoredToken;
                AccountId = StoredAccountId;
            }
            else
            {
                var LoginWindow = new EpicLogin();
                var LoginResult = LoginWindow.ShowDialog();
                if (LoginResult.HasValue && LoginResult.Value)
                {
                    StoredToken     = Token = LoginWindow.Token;
                    StoredAccountId = AccountId = LoginWindow.AccountId;
                }
                else
                {
                    return;
                }
            }

            VerifyToken();

            string UniqueFilename = null;

            var FileBrowser = new CloudFileBrowser(Token, AccountId);
            var Result      = FileBrowser.ShowDialog();

            if (Result.HasValue && Result.Value)
            {
                UniqueFilename = FileBrowser.SelectedUniqueFilename;
            }

            if (UniqueFilename == null)
            {
                return;
            }

            var Request = new RestRequest("fortnite/api/cloudstorage/user/" + AccountId + "/" + UniqueFilename, Method.GET);

            Request.AddHeader("Authorization", "bearer " + Token);

            var Client = new RestClient("https://fortnite-public-service-prod11.ol.epicgames.com");

            Client.ExecuteAsync(Request, Response =>
            {
                using (var Stream = new MemoryStream(Response.RawBytes))
                {
                    if (OpenFromStream(Stream))
                    {
                        Application.Current.Dispatcher.Invoke(() => MVM.CanSaveFile = true);
                    }
                }
            });
        }
Ejemplo n.º 2
0
        private void CloudExport_Click(object sender, RoutedEventArgs e)
        {
            string Token, AccountId;

            if (StoredToken != null && StoredAccountId != null && VerifyToken())
            {
                Token     = StoredToken;
                AccountId = StoredAccountId;
            }
            else
            {
                var LoginWindow = new EpicLogin();
                var LoginResult = LoginWindow.ShowDialog();
                if (LoginResult.HasValue && LoginResult.Value)
                {
                    StoredToken     = Token = LoginWindow.Token;
                    StoredAccountId = AccountId = LoginWindow.AccountId;
                }
                else
                {
                    return;
                }
            }

            string UniqueFilename = null;

            var FileBrowser = new CloudFileBrowser(Token, AccountId);
            var Result      = FileBrowser.ShowDialog();

            if (Result.HasValue && Result.Value)
            {
                UniqueFilename = FileBrowser.SelectedUniqueFilename;
            }

            if (UniqueFilename == null)
            {
                return;
            }

            using (var Stream = new MemoryStream())
            {
                if (SaveToStream(Stream))
                {
                    var Request = new RestRequest("fortnite/api/cloudstorage/user/" + AccountId + "/" + UniqueFilename, Method.PUT);
                    Request.AddHeader("Authorization", "bearer " + Token);
                    Request.AddHeader("Content-Type", "application/octet-stream");
                    Request.AddParameter("application/octet-stream", Stream.ToArray(), ParameterType.RequestBody);

                    var Client = new RestClient("https://fortnite-public-service-prod11.ol.epicgames.com");
                    Client.ExecuteAsync(Request, Response =>
                    {
                        Application.Current.Dispatcher.Invoke(() => MessageBox.Show(Response.StatusCode.ToString(), "Status", MessageBoxButton.OK, MessageBoxImage.Information));
                    });
                }
            }
        }