Comments (5)
@adibsyahmi17 unfortunately, TaskSnapshot does not have a getDownloadUrl()
method. You'll need to call that method on the StorageReference
that you created to upload the file.
from codelab-friendlychat-android.
@adibsyahmi17 unfortunately, TaskSnapshot does not have a
getDownloadUrl()
method. You'll need to call that method on theStorageReference
that you created to upload the file.
can you show me how because this is my first time using android studio
from codelab-friendlychat-android.
@adibsyahmi17 Can you show the code where you create the StorageReference
? The one that comes before this onSuccess
code that you posted here.
from codelab-friendlychat-android.
if (imageURI != null){
StorageReference fileReference = storageReference.child(System.currentTimeMillis()
+ "." + getFileExtension(imageURI));
fileReference.putFile(imageURI)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@OverRide
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@OverRide
public void run() {
mProgressBar.setProgress(0);
}
}, 500);
Toast.makeText(AddSolatPage.this, "Upload successful", Toast.LENGTH_LONG).show();
Upload upload = new Upload(solatTitle.getText().toString().trim(),
taskSnapshot.getStorage().getDownloadUrl().toString());
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(AddSolatPage.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
})
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(@NonNull UploadTask.TaskSnapshot snapshot) {
double progress = (100.0 * snapshot.getBytesTransferred() / snapshot.getTotalByteCount());
mProgressBar.setProgress((int) progress);
}
});
}else {
Toast.makeText(this,"No file selected",Toast.LENGTH_SHORT).show();
}
this is my code
from codelab-friendlychat-android.
@adibsyahmi17 Thanks for providing the code. You'll need to change your onSuccess method to reuse the StorageReference
that you created:
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
mProgressBar.setProgress(0);
}
}, 500);
Toast.makeText(AddSolatPage.this, "Upload successful", Toast.LENGTH_LONG).show();
fileReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String url = uri.toString();
Upload upload = new Upload(solatTitle.getText().toString().trim(), url);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
}
from codelab-friendlychat-android.
Related Issues (20)
- I separated the Java and Kotlin version HOT 2
- default_web_client_id HOT 2
- Replace startActivityForResult
- Add more stringent Cloud Storage rules HOT 1
- If done to exact spec, App will crash on launch. HOT 2
- Include code for goToMainActivity()
- No instruction on `private fun signIn` in SignInActivity.kt
- mock-google-services file missing HOT 1
- API key not valid HOT 11
- messageImageView typo in step 7 HOT 5
- AuthUI.getInstance().signOut() missing 'this' HOT 1
- LinearLayoutManager tends to crash when new image inserted HOT 3
- USB Debugging
- Sign in with email: NEXT button does not work HOT 1
- Don't have gradle version 8.0.2
- Can't copy mock-google-services.json file to build-android-start/app folder
- Kepp getting error code 10 when logging with Google account
- MainActivity crash because of 'the default_web_client_id string wasn't populated' HOT 1
- com.firebaseui:firebase-ui-auth needs an upgrade HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codelab-friendlychat-android.