use of com.google.firebase.storage.StorageMetadata in project Tapad by berict.
the class PresetStoreAdapter method onFirebasePresetUpdated.
private void onFirebasePresetUpdated(final String presetName, final Runnable onUpdated) {
StorageReference metadataReference = FirebaseStorage.getInstance().getReferenceFromUrl("gs://tapad-4d342.appspot.com/presets/" + presetName).child("preset.zip");
metadataReference.getMetadata().addOnSuccessListener(new OnSuccessListener<StorageMetadata>() {
@Override
public void onSuccess(StorageMetadata storageMetadata) {
Log.d(TAG, "Successful getting metadata");
if (storageMetadata.getUpdatedTimeMillis() > new File(PROJECT_LOCATION_PRESETS + "/" + presetName + "/about/json.txt").lastModified()) {
// firebase preset is updated since last download
// get the new updated preset
Log.d(TAG, "Preset updated");
onUpdated.run();
} else {
Log.d(TAG, "Preset not updated");
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "Failed to get preset metadata");
}
});
}
use of com.google.firebase.storage.StorageMetadata in project Tapad by berict.
the class FirebaseHelper method getStorageMetadata.
public StorageMetadata getStorageMetadata(StorageReference storageReference, Activity activity) {
FirebaseApp.initializeApp(activity);
final StorageMetadata[] mStorageMetadata = { null };
storageReference.getMetadata().addOnSuccessListener(new OnSuccessListener<StorageMetadata>() {
@Override
public void onSuccess(StorageMetadata storageMetadata) {
Log.d(TAG, "Successful getting metadata");
mStorageMetadata[0] = storageMetadata;
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "Failed to get metadata");
}
});
return mStorageMetadata[0];
}
use of com.google.firebase.storage.StorageMetadata in project Carebase by robertsimoes.
the class CarebaseDatabase method uploadProfilePhoto.
@Override
public void uploadProfilePhoto(String userId, Uri photo, OnSuccessListener callback) {
StorageMetadata metadata = new StorageMetadata.Builder().setContentType("image/jpg").build();
profilePhotoStorage.child(userId).putFile(photo, metadata).addOnSuccessListener(callback);
}
use of com.google.firebase.storage.StorageMetadata in project BORED by invent2017.
the class StoryUpload method uploadImage.
private void uploadImage(Uri file) {
// String fileUri = file.toString();
// File imageFile = new File(fileUri);
StorageMetadata metadata = new StorageMetadata.Builder().setContentType("image/jpg").build();
String imageFileName = file.getLastPathSegment();
// TODO: check if image with same name already exists
UploadTask uploadTask = mStorageRef.child(imageFileName).putFile(file, metadata);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
builder.setMessage("Upload failed. Please try again later.").setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent i = new Intent(StoryUpload.this, MapsActivityCurrentPlace.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
builder.create().show();
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
uploadImageData(taskSnapshot);
}
});
}
use of com.google.firebase.storage.StorageMetadata in project Firebase-Helper by AtifAbbAsi19.
the class FireBaseHelper method uploadAudio.
public void uploadAudio(Uri uri, StorageReference filePath, FirebaseUrlCallInterface urlAudioCallInterface) {
this.firebaseAudioUrlCallInterface = urlAudioCallInterface;
progressDialog.setMessage(context.getString(R.string.loading));
progressDialog.show();
// Create file metadata including the content type
StorageMetadata metadata = new StorageMetadata.Builder().setContentType("audio/mpeg").build();
filePath = mFStorage.child("audio").child(getRandomId() + ".mp3");
filePath.putFile(galleryUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
progressDialog.dismiss();
String url = taskSnapshot.getDownloadUrl().toString();
firebaseAudioUrlCallInterface.onFirebaseCallComplete(url);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
progressDialog.dismiss();
firebaseAudioUrlCallInterface.onFirebaseCallFailure(exception);
// Toast.makeText(getApplicationContext(), exception.getMessage(), Toast.LENGTH_LONG).show();
}
}).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
// displaying the upload progress
double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
progressDialog.setMessage("Uploaded " + ((int) progress) + "%...");
}
});
}
Aggregations