所以我试图让用户从他们的照片库中选择一张图像,然后将其上传到 Firebase Storage...到目前为止,我的代码如下所示:
@Override
protected void onActivityResult(int requestCode,int resultcode, Intent data){
super.onActivityResult(requestCode,resultcode,data);
if(requestCode == REQUEST_IMAGE_CAPTURE && resultcode == RESULT_OK) {
final Uri uri = data.getData();
if (uri != null){
Bitmap bmp = null;
try {
bmp = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
} catch (IOException e){
e.printStackTrace();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 25, baos);
byte[] fileInBytes = baos.toByteArray();
bmp.recycle();
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseStorage storage = FirebaseStorage.getInstance();
String imageString = "";
if(clickPhoto ==1){imageString = "Image 1"; }
else if(clickPhoto ==2){imageString = …Run Code Online (Sandbox Code Playgroud) 我正在使用 Stripe Connect,并且已成功加入 3 个商家。我正在尝试产生付款意向,并且我一直得到
“无权访问帐户 '{{acct_1FvpC4JkgwMoBOTZ}}'(或者该帐户不存在)。”但我正在使用的 SECRET api 密钥匹配且未更改。我的平台显然也有客户和商家加入:
商人:
NODE.JS 初始化:
const stripe = require('stripe')(StripeKey);
Run Code Online (Sandbox Code Playgroud)
@param CONNECTED_STRIPE_ACCOUNT_ID = acct_1FvpC4JkgwMoBOTZ
@param customerId = cus_GSe2V6snvtLlQs
代码:
exports.onDonationFinance = functions.database.ref("/Stripe/{donationId}").onCreate((snapshot,context)=>{
var amount = snapshot.child("amount").val();
var email = snapshot.child("email").val();
const CONNECTED_STRIPE_ACCOUNT_ID = snapshot.child("conn_id").val();
const customerId = snapshot.child("cus_id").val();
const id = context.params.donationId;
const token = generateToken(customerId,CONNECTED_STRIPE_ACCOUNT_ID);
if(amount===0){
amount =250;
}else if(amount ===1){
amount =500;
}else if(amount ===2){
amount =1000;
}else if(amount ===3){
amount =1500;
}
const applicationFee = Math.round((amount/100)*1.45);
stripe.customers.create({
source: token …Run Code Online (Sandbox Code Playgroud) 所以我有一个用例,用户可能需要多个自定义声明,但在应用程序的不同点添加,即用户可以既是店主又是店主,或者他们可能只是店主或只是用户。
我通过文档了解到,当您分配新的自定义声明时,它会覆盖原始声明,因此我需要阅读用户当前拥有的声明。这就是我被卡住的地方......在我收到索赔后,我如何将它们重新写回给用户?
exports.onGameManagement = functions.database.ref("Core/CoreGames/{game}/teams/committee").onCreate((snapshot,context)=>{
const position = snapshot.key;
const uid = snapshot.val();
const game = context.params.game;
if(position=="gLead"||position=="depGameLead"){
//NEEDS ADMIN RIGHTS
//ADD TOKEN WRITE RIGHTS. - check for current claims
admin.auth().getUser(uid).then((userRecord)=>{
//got the users claims
console.log(userRecord.customClaims);
//how do i add this array of claims to the setCustomUserClaims() method?
admin.auth().setCustomUserClaims(uid, {gameAdmin: true, userRecord.customClaims}).then(() => {
// The new custom claims will propagate to the user's ID token the
// next time a new one is issued.
});
})
}else{
}
}) …Run Code Online (Sandbox Code Playgroud) javascript firebase firebase-authentication google-cloud-functions firebase-admin
我觉得我错过了一些非常简单的东西,但我似乎找不到多少帮助.所以我在mem SQL数据库中使用vaadin和h2设计登录.有一种方法可以从列表中的数据库中返回值.麻烦的是我遇到了以下方法的问题.这意味着遍历列表中的每个条目,如果找到匹配的用户名/密码,则返回true.如果没有返回假.....
public boolean checkUserInDatabase(String username, String email) {
boolean result = false;
List<User> localArray = getUserList();
System.out.println("List retrieved...Checking user in database"+
localArray);
for (User u : localArray ) {
if (u.getUsername().equals(username)) {
result = true;
}
else {
result = false;
}
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
我知道在这一点上我只是检查用户名,但是当我将用户添加到数据库时,它仍然只会检查该数据库中的最后一个用户....想法?