本文整理汇总了Java中com.google.firebase.storage.FirebaseStorage.getReferenceFromUrl方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseStorage.getReferenceFromUrl方法的具体用法?Java FirebaseStorage.getReferenceFromUrl怎么用?Java FirebaseStorage.getReferenceFromUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.firebase.storage.FirebaseStorage
的用法示例。
在下文中一共展示了FirebaseStorage.getReferenceFromUrl方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FindandCollectProductPdfFileLink
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
public void FindandCollectProductPdfFileLink(String ProductName, String Manufacter){
FirebaseStorage mStor = FirebaseStorage.getInstance();
StorageReference mFindPdfStorageReference = mStor.getReferenceFromUrl("gs://farmers-helper-44f7a.appspot.com/"+Manufacter+"/"+ProductName+"/"+ProductName+".pdf");
mFindPdfStorageReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
mPdfUrl = String.valueOf(uri);}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
mPdfUrl="";
}
});
}
示例2: configureMyChatViewHolder
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
private void configureMyChatViewHolder(final MyChatViewHolder myChatViewHolder, int position) {
final Chat chat = mChats.get(position);
//String alphabet = chat.sender.substring(0, 1);
myChatViewHolder.txtChatMessage.setText(chat.message);
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl(context.getResources().getString(R.string.storage_link));
storageRef.child("profilePictures/" + chat.sender + ".jpg").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
try {
Glide.with(myChatViewHolder.imgViewUser.getContext())
.load("" + uri.toString())
.diskCacheStrategy(DiskCacheStrategy.ALL) //use this to cache
.into(myChatViewHolder.imgViewUser);
} catch (Exception ignored) {
}
}
});
myChatViewHolder.imgViewUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(myChatViewHolder.imgViewUser.getContext(), ProfileActivity.class);
Bundle b = new Bundle();
b.putString("key", chat.sender); //Your id
intent.putExtras(b); //Put your id to your next Intent
myChatViewHolder.imgViewUser.getContext().startActivity(intent);
}
});
// myChatViewHolder.imgViewUser.setText(alphabet);
}
示例3: configureOtherChatViewHolder
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
private void configureOtherChatViewHolder(final OtherChatViewHolder otherChatViewHolder, int position) {
final Chat chat = mChats.get(position);
otherChatViewHolder.txtChatMessage.setText(chat.message);
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl(context.getResources().getString(R.string.storage_link));
storageRef.child("profilePictures/" + chat.sender + ".jpg").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
try {
Glide.with(otherChatViewHolder.imgViewUser.getContext())
.load("" + uri.toString())
.diskCacheStrategy(DiskCacheStrategy.ALL) //use this to cache
.into(otherChatViewHolder.imgViewUser);
} catch (Exception ignored) {
}
}
});
otherChatViewHolder.imgViewUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(otherChatViewHolder.imgViewUser.getContext(), ProfileActivity.class);
Bundle b = new Bundle();
b.putString("key", chat.sender); //Your id
intent.putExtras(b); //Put your id to your next Intent
otherChatViewHolder.imgViewUser.getContext().startActivity(intent);
}
});
//otherChatViewHolder.imgViewUser.setText(alphabet);
}
示例4: uploadFile
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
@Override
public Promise<String, BError, SaveImageProgress> uploadFile(byte[] data, String name, String mimeType) {
final Deferred<String, BError, SaveImageProgress> deferred = new DeferredObject<>();
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl(BDefines.FirebaseStoragePath);
StorageReference filesRef = storageRef.child("files");
final String fullName = getUUID() + "_" + name;
StorageReference fileRef = filesRef.child(fullName);
UploadTask uploadTask = fileRef.putBytes(data);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
if (DEBUG) Timber.e(e.getCause(), "Firebase storage exception while saving");
deferred.reject(new BError(BError.Code.FIREBASE_STORAGE_EXCEPTION, e));
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// taskSnapshot.getMetadata() contains file metadata such as size, content-type, and download URL.
deferred.resolve(taskSnapshot.getDownloadUrl().toString());
}
});
return deferred.promise();
}
示例5: deleteHouse
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
@Override
public void deleteHouse(Home home) {
// Get the storage reference
FirebaseStorage storage = FirebaseStorage.getInstance();
FirebaseOptions opts = FirebaseApp.getInstance().getOptions();
StorageReference storageRef = storage.getReferenceFromUrl("gs://" + opts.getStorageBucket());
String[] imageName = home.getDownloadImage().split("%2F", 3); // And get the image name
String[] imgName = imageName[2].split("alt", 2);
imgName[0] = imgName[0].substring(0, imgName[0].length() - 1);
StorageReference desertRef = storageRef.child("homes").child(home.getUid()).child(imgName[0]);
// Delete the file
desertRef.delete().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Log.d("TAG", "Éxito!");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d("TAG", "Problemas");
}
});
// Remove the listing
databaseReference.child("homes").child(home.getUid()).removeValue();
Log.d("DELETE", databaseReference.toString());
launchManageFragment();
}
示例6: onCreate
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.N)
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
setHasOptionsMenu(true);
EventBus.getDefault().register(this);
mUserId = FirebaseAuth.getInstance().getCurrentUser().getUid();
FirebaseStorage firebaseStorage = FirebaseStorage.getInstance();
mStorageReference = firebaseStorage.getReferenceFromUrl(Constants.FB_STORAGE_REFERENCE);
mInputMethodManager = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
mPaddingBottom = getResources().getDimensionPixelOffset(R.dimen.padding_bottom);
if (getArguments() != null) {
moonlight = getArguments().getParcelable("moonlight");
if (moonlight != null) {
mKeyId = moonlight.getId();
if (BuildConfig.DEBUG) { Log.d(TAG, "keyId: " + mKeyId); }
}
int trashTag = getArguments().getInt("flag");
if (trashTag == 0) {
mEditFlag = true;
mCreateFlag = false;
} else {
mEditFlag = true;
mCreateFlag = false;
mEditable = false;
}
} else {
moonlight = new Moonlight();
}
((DrawerLocker) mActivity).setDrawerEnabled(false);
initColor();
}
示例7: onBindViewHolder
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
final User user = mUsers.get(position);
String alphabet;
// holder.txtLastMessage.setText(user.email);
try {
holder.txtUsername.setText(user.nameAndSurname);
alphabet = user.nameAndSurname.substring(0, 1);
} catch (Exception e) {
holder.txtUsername.setText(user.email);
alphabet = user.email.substring(0, 1);
}
// holder.txtUserAlphabet.setText(alphabet);
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl(context.getResources().getString(R.string.storage_link));
storageRef.child("profilePictures/" + user.email + ".jpg").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
try {
Glide
.with(holder.imgViewUser.getContext())
.load("" + uri.toString())
.diskCacheStrategy(DiskCacheStrategy.ALL) //use this to cache
.into(holder.imgViewUser);
} catch (Exception ignored) {
}
}
});
holder.imgViewUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(holder.imgViewUser.getContext(), ProfileActivity.class);
Bundle b = new Bundle();
b.putString("key", user.email); //Your id
intent.putExtras(b); //Put your id to your next Intent
holder.imgViewUser.getContext().startActivity(intent);
}
});
}
示例8: onBindViewHolder
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
final User user = mUsers.get(position);
// holder.txtLastMessage.setText(dataSnapshot.child("message").getValue().toString());
// todo yap buralari holder.txtNotificationCount.setBackground(ContextCompat.getDrawable(holder.txtNotificationCount.getContext(), R.drawable.circle_accent));
// holder.txtNotificationCount.setText("1");
// holder.txtLastMessage.setTypeface(null, Typeface.BOLD);
// holder.txtUsername.setTypeface(null, Typeface.BOLD);
try {
holder.txtUsername.setText(user.nameAndSurname);
} catch (Exception e) {
holder.txtUsername.setText(user.email);
}
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl(context.getResources().getString(R.string.storage_link));
storageRef.child("profilePictures/" + user.email + ".jpg").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
try {
Glide
.with(holder.imgViewUser.getContext())
.load("" + uri.toString())
.diskCacheStrategy(DiskCacheStrategy.ALL) //use this to cache
.into(holder.imgViewUser);
} catch (Exception ignored) {
}
}
});
holder.imgViewUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(holder.imgViewUser.getContext(), ProfileActivity.class);
Bundle b = new Bundle();
b.putString("key", user.email); //Your id
intent.putExtras(b); //Put your id to your next Intent
holder.imgViewUser.getContext().startActivity(intent);
}
});
}
示例9: uploadReport
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
private void uploadReport() {
progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Uploading");
progressDialog.setMessage("Please wait...");
progressDialog.setIndeterminate(true);
progressDialog.show();
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://crimsonnew-33e2c.appspot.com");
final String uuid = UUID.randomUUID().toString();
String name= "reports/test"+uuid+".jpg";
spaceRef = storageRef.child(name);
imageView.setDrawingCacheEnabled(true);
imageView.buildDrawingCache();
Bitmap bitmap = imageView.getDrawingCache();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] data = baos.toByteArray();
UploadTask uploadTask = spaceRef.putBytes(data);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle unsuccessful uploads
progressDialog.dismiss();
Toast.makeText(SaveReports.this,"Failed to upload.",Toast.LENGTH_SHORT).show();
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// taskSnapshot.getMetadata() contains file metadata such as size, content-type, and download URL.
Uri downloadUrl = taskSnapshot.getDownloadUrl();
reportsRef.child(uuid).setValue(downloadUrl.toString());
imageView.refreshDrawableState();
progressDialog.dismiss();
Toast.makeText(SaveReports.this,"Uploaded successfully.",Toast.LENGTH_SHORT).show();
imageView.refreshDrawableState();
}
});
}
示例10: onCreate
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_upload_photo);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
mContext = this;
// Initialize Firebase Auth
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseUser = mFirebaseAuth.getCurrentUser();
//Firebase storage
FirebaseStorage storage = FirebaseStorage.getInstance();
if (mFirebaseUser == null) {
// Not signed in, launch the Sign In activity
startActivityForResult(AuthUI.getInstance().createSignInIntentBuilder()
.setProviders(Arrays.asList(
new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build()))
.setTheme(R.style.SignInTheme)
.build(),
RC_SIGN_IN);
return;
} else {
mUsernameId = mFirebaseUser.getUid();
mUsername = mFirebaseUser.getDisplayName();
mPhotoUrl = mFirebaseUser.getPhotoUrl().toString();
}
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API)
.build();
mDatabaseReference = FirebaseDatabase.getInstance().getReference();
// Create a storage reference from our app
storageRef = storage.getReferenceFromUrl("gs://keralaattractions-fd4fe.appspot.com");
edTitle = (EditText) findViewById(R.id.etTitle);
edPlace = (EditText) findViewById(R.id.etPlace);
edDescription = (EditText) findViewById(R.id.etDescription);
imageView = (ImageButton) findViewById(R.id.imageView);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
performFileSearch();
}
});
FloatingActionButton fabUpload = (FloatingActionButton) findViewById(R.id.fabUpload);
fabUpload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
submitPhoto();
}
});
}
示例11: onActivityResult
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 1 && resultCode == RESULT_OK && data!=null){
//
ProgressDialog progressDialog = new ProgressDialog(LocationPhoto.this);
progressDialog.setMessage("Wait while the image is uploaded....");
progressDialog.setCancelable(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.show();
Log.d("Image URI","in here");
// Bitmap photo = (Bitmap)data.getExtras().get("data");
// Uri selectedImage = data.getData();
// String imagesel =
// File finalFile = new File(getRealPathFromURI(selectedImage));
// Uri selectedImag = data.getData();
//if(b == false)
//{
Bitmap photo = (Bitmap)data.getExtras().get("data");
Uri selectedImage = getImageUri(LocationPhoto.this,photo);
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://synergy-go.appspot.com");
StorageReference photoRef = storageRef.child(Type).child(fileno).child(selectedImage.getLastPathSegment());
photoRef.putFile(selectedImage);
progressDialog.dismiss();
Toast.makeText(this,"Image Uploaded", Toast.LENGTH_SHORT).show();
//} else {
// Toast.makeText(getApplicationContext(),"THis is it",Toast.LENGTH_LONG).show();
//}
// Log.d("Image URI",selectedImage.toString());
//Bundle extra = data.getExtras();
//photos = (Bitmap)extra.get("data");
// int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
//
//
// if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
// ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},EXTERNAL_STORAGE_CODE);
// } else {
// // selectedImage = getImageUri(LocationPhoto.this,photos);
//
// }
}
else {
Toast.makeText(getApplicationContext(),"Image not uploaded",Toast.LENGTH_LONG).show();
// Intent intent = new Intent(LocationPhoto.this,LocationPhoto.class);
// startActivity(intent);
}
}
示例12: getFirebaseStorageRef
import com.google.firebase.storage.FirebaseStorage; //导入方法依赖的package包/类
public static StorageReference getFirebaseStorageRef() {
FirebaseStorage storage = FirebaseStorage.getInstance();
return storage.getReferenceFromUrl("gs://plus-one-59ee5.appspot.com");
}