如何增加图片文件名的Firebase

时间:2018-07-07 18:50:48

标签: android firebase firebase-storage

我正在尝试在上传新图像时增加图像文件名,但是它不起作用 这是代码:

public int getImageCount(DataSnapshot dataSnapshot) {
        int count = 0;
        for (DataSnapshot ds : dataSnapshot
                .child(mContext.getString(R.string.dbname_user_posts))
                .child(FirebaseAuth.getInstance().getCurrentUser().getUid())
                .getChildren()) {
            count++;
        }
        return count;
    }

    public void uploadNewPost(final String caption, int count, String imgUrl, Bitmap bm) {
        Log.d(TAG, "uploadNewPost: Attempting to upload new post");

        FilePaths filePaths = new FilePaths();

        String user_id = Objects.requireNonNull(FirebaseAuth.getInstance().getCurrentUser()).getUid();

        StorageReference storageReference = mStorageReference
                .child(filePaths.FIREBASE_IMAGE_STORAGE + "/" + user_id + "/photo" + (count++));

0 个答案:

没有答案