0
我创建了一个简单的应用程序,用户必须将图像从图库上传到Firebase。第一次裁剪图像,但现在如何保存裁剪后的图像。如何将作物图像保存在Firebase中
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
su = (TextView) findViewById(R.id.sub);
name = (EditText) findViewById(R.id.namee);
register = (Button) findViewById(R.id.sigupp);
emaill = (EditText) findViewById(R.id.emaitext);
password = (EditText) findViewById(R.id.passtext);
mAuth = FirebaseAuth.getInstance();
mStorageImage= FirebaseStorage.getInstance().getReference()
.child("profile_images");
mProgres = new ProgressDialog(this);
photo=(ImageView)findViewById(R.id.welcom);
mReference = FirebaseDatabase.getInstance().getReference().child("user");
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
// Log.d(TAG, "onAuthStateChanged:signed_in:" +
user.getUid());
} else {
// User is signed out
// Log.d(TAG, "onAuthStateChanged:signed_out");
// Intent i=new Intent(MainActivity.this,Home.class);
//startActivity(i);
}
// ...
并且这是图像被裁剪的代码。
photo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent imageDownload=new Intent();
imageDownload.setAction(Intent.ACTION_GET_CONTENT);
imageDownload.setType("image/*");
imageDownload.putExtra("crop", "true");
imageDownload.putExtra("aspectX", 1);
imageDownload.putExtra("aspectY", 1);
imageDownload.putExtra("outputX", 200);
imageDownload.putExtra("outputY", 200);
imageDownload.putExtra("return-data", true);
startActivityForResult(imageDownload, GALLERY_REQUEST_CODE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == GALLERY_REQUEST_CODE && resultCode == RESULT_OK &&
data != null) {
Bundle extras = data.getExtras();
image = extras.getParcelable("data");
photo.setImageBitmap(image);
}
//}
现在我该如何将此图片保存到Firebase。