コード例 #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);
        }