step-up-labs / firebase-storage-dotnet

C# library for Firebase Storage
MIT License
140 stars 35 forks source link

bad request 400 for Firebase Storage #28

Closed luckyjasperwei closed 4 years ago

luckyjasperwei commented 4 years ago

Hi, i'm getting bad request 400 error when i am verifying and uploading the file to get the download url . i use FirebaseAuthentication.net , FirebaseStorage.net I use the sample code like this

it get error until downloadurl and can't get the file in firebase storage

wirte rule:

rules_version = '2'; service firebase.storage { match /b/{bucket}/o { match /{allPaths=**} { allow read, write:if request.auth!=null; } }

this is the code

var authProvider = new FirebaseAuthProvider(new FirebaseConfig("APIKEY")); FirebaseAuth auth = await authProvider.SignInWithEmailAndPasswordAsync(account.Email, account.PW); var stream = File.Open(@"C:\sample.jpg", FileMode.Open);
var cancellation = new CancellationTokenSource(); string Bucket = "gs://xxxxxxx.appspot.com/";

            var hello= new FirebaseStorage(
            Bucket,
            new FirebaseStorageOptions
            {
                AuthTokenAsyncFactory = () => Task.FromResult(auth.FirebaseToken),
                ThrowOnCancel = true 
            }).Child("test").Child("test2").Child("sample.jpg").PutAsync(stream, cancellation.Token);

            var downloadurl = await hello;
luckyjasperwei commented 4 years ago

i had already solve by this , the url should be modify , thanks