Ejemplo n.º 1
0
        public async Task <bool> Upload(FileStream stream, string filenanme, Publicacion obj)
        {
            conexion = new Conexion();
            string link = "";

            if (stream != null)
            {
                var auth = new FirebaseAuthProvider(new FirebaseConfig(conexion.Firekey()));
                var a    = await auth.SignInWithEmailAndPasswordAsync(conexion.AthEmail(), conexion.AthPassword());

                var cancellation = new CancellationTokenSource();
                var task         = new FirebaseStorage(
                    conexion.Storge(),
                    new FirebaseStorageOptions
                {
                    AuthTokenAsyncFactory = () => Task.FromResult(a.FirebaseToken),
                    ThrowOnCancel         = true // when you cancel the upload, exception is thrown. By default no exception is thrown
                })
                                   .Child("Publicaciones")
                                   .Child(filenanme)
                                   .PutAsync(stream, cancellation.Token);
                link = await task;
            }

            try
            {
                Task tarea2 = Task.Run(() => Create_Publicacion(obj, link));
            }

            catch (Exception ex)
            {
                Console.WriteLine("Exception was thrown: {0}", ex);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public async Task <bool> CrearUsuario(Usuario o)
        {
            try
            {
                conexion = new Conexion();
                var auth = new FirebaseAuthProvider(new FirebaseConfig(conexion.Firekey()));
                var a    = await auth.CreateUserWithEmailAndPasswordAsync(o.correo_usuario, o.password, o.nombre_usuario, true);

                var id = a.User.LocalId;  //para tener el id del usuario que esta registrado we :V
                client = new FireSharp.FirebaseClient(conexion.conec());
                var data = o;
                data.id_usuario = id;
                SetResponse setResponse = client.Set("Usuario/" + data.id_usuario, data);
            }
            catch (Exception ex)
            {
            }
            return(true);
        }