当前位置: 首页>>代码示例>>Java>>正文


Java StorageReference.child方法代码示例

本文整理汇总了Java中com.google.firebase.storage.StorageReference.child方法的典型用法代码示例。如果您正苦于以下问题:Java StorageReference.child方法的具体用法?Java StorageReference.child怎么用?Java StorageReference.child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.firebase.storage.StorageReference的用法示例。


在下文中一共展示了StorageReference.child方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendFileFirebase

import com.google.firebase.storage.StorageReference; //导入方法依赖的package包/类
private void sendFileFirebase(StorageReference storageReference, final Uri file) {
    if (storageReference != null) {
        final String name = DateFormat.format("yyyy-MM-dd_hhmmss", new Date()).toString();
        StorageReference imageGalleryRef = storageReference.child(name + "_gallery");
        UploadTask uploadTask = imageGalleryRef.putFile(file);
        uploadTask.addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Log.e(TAG, "onFailure sendFileFirebase " + e.getMessage());
            }
        }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                Log.i(TAG, "onSuccess sendFileFirebase");
                Uri downloadUrl = taskSnapshot.getDownloadUrl();
                FileModel fileModel = new FileModel("img", downloadUrl.toString(), name, "");
                ChatModel chatModel = new ChatModel(userModel, "", Calendar.getInstance().getTime().getTime() + "", fileModel);
                mFirebaseDatabaseReference.child(Constants.events).child(evekey).child(Constants.chatmodel).push().setValue(chatModel);
            }
        });
    } else {
        //IS NULL
    }
}
 
开发者ID:picopalette,项目名称:event-me,代码行数:25,代码来源:MessagingActivity.java

示例2: includesForDeleteFiles

import com.google.firebase.storage.StorageReference; //导入方法依赖的package包/类
private void includesForDeleteFiles() {
    FirebaseStorage storage = FirebaseStorage.getInstance();

    // [START delete_file]
    // Create a storage reference from our app
    StorageReference storageRef = storage.getReference();

    // Create a reference to the file to delete
    StorageReference desertRef = storageRef.child("images/desert.jpg");

    // Delete the file
    desertRef.delete().addOnSuccessListener(new OnSuccessListener<Void>() {
        @Override
        public void onSuccess(Void aVoid) {
            // File deleted successfully
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception exception) {
            // Uh-oh, an error occurred!
        }
    });
    // [END delete_file]
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:25,代码来源:StorageActivity.java

示例3: uploadFile

import com.google.firebase.storage.StorageReference; //导入方法依赖的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();
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:29,代码来源:BFirebaseUploadHandler.java

示例4: onActivityResult

import com.google.firebase.storage.StorageReference; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    StorageReference storageRef = storage.getReferenceFromUrl(Utils.URL_STORAGE_REFERENCE).child(Utils.FOLDER_STORAGE_IMG);

    if (requestCode == IMAGE_GALLERY_REQUEST) {
        if (resultCode == RESULT_OK) {
            Uri selectedImageUri = data.getData();
            if (selectedImageUri != null) {
                sendFileFirebase(storageRef, selectedImageUri);
            }
        }
    }
    else if (requestCode == IMAGE_CAMERA_REQUEST) {
        if (resultCode == RESULT_OK) {
            if (filePathImageCamera != null && filePathImageCamera.exists()) {
                StorageReference imageCameraRef = storageRef.child(filePathImageCamera.getName() + "_camera");
                sendFileFirebase(imageCameraRef, filePathImageCamera);
            }
        }
    }
    else if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(this, data);
            if (place != null) {
                LatLng latLng = place.getLatLng();
                MapModel mapModel = new MapModel(latLng.latitude + "", latLng.longitude + "");
                ChatModel chatModel = new ChatModel(userModel, Calendar.getInstance().getTime().getTime() + "", mapModel);
                mFirebaseDatabaseReference.child(room).push().setValue(chatModel);
            }
        }
    }


}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:36,代码来源:ChatActivity.java

示例5: onCreate

import com.google.firebase.storage.StorageReference; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    // Get a reference to Firebase Storage
    StorageReference storageRef = FirebaseStorage.getInstance().getReferenceFromUrl("gs://lammsite-fc813.appspot.com");
    // Get a reference to the Arduinos folder
    mArduinoStorageRef = storageRef.child("arduinos");

    // Get a reference to Firebase Database
    mDatabaseRef = FirebaseDatabase.getInstance().getReferenceFromUrl("https://lammsite-fc813.firebaseio.com");
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:13,代码来源:FirebaseUploadService.java

示例6: uploadImage

import com.google.firebase.storage.StorageReference; //导入方法依赖的package包/类
public UploadTask uploadImage(Uri uri, String imageTitle) {
    StorageReference storageRef = storage.getReferenceFromUrl(context.getResources().getString(R.string.storage_link));
    StorageReference riversRef = storageRef.child("images/" + imageTitle);
    // Create file metadata including the content type
    StorageMetadata metadata = new StorageMetadata.Builder()
            .setCacheControl("max-age=7776000, Expires=7776000, public, must-revalidate")
            .build();

    return riversRef.putFile(uri, metadata);
}
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:11,代码来源:DatabaseHelper.java

示例7: includesForMetadata_delete

import com.google.firebase.storage.StorageReference; //导入方法依赖的package包/类
private void includesForMetadata_delete() {
    FirebaseStorage storage = FirebaseStorage.getInstance();
    StorageReference storageRef = storage.getReference();
    StorageReference forestRef = storageRef.child("images/forest.jpg");

    // [START delete_file_metadata]
    // Create file metadata with property to delete
    StorageMetadata metadata = new StorageMetadata.Builder()
            .setContentType(null)
            .build();

    // Delete the metadata property
    forestRef.updateMetadata(metadata)
            .addOnSuccessListener(new OnSuccessListener<StorageMetadata>() {
                @Override
                public void onSuccess(StorageMetadata storageMetadata) {
                    // metadata.contentType should be null
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {
                    // Uh-oh, an error occurred!
                }
            });
    // [END delete_file_metadata]
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:28,代码来源:StorageActivity.java

示例8: updatingProcess

import com.google.firebase.storage.StorageReference; //导入方法依赖的package包/类
void updatingProcess(){

        Toast.makeText(upload2.this,"File database Updated", Toast.LENGTH_LONG).show();

        finish();

        startActivity(new Intent(upload2.this, cs.class));

        StorageReference storageRef = storage.getReferenceFromUrl("https://paathshala-359ec.firebaseio.com/Computer Science");

        StorageReference storageRef1 = storageRef.child(Name);


        finish();



    }
 
开发者ID:nSpider,项目名称:Paathshala,代码行数:19,代码来源:upload2.java

示例9: onCreate

import com.google.firebase.storage.StorageReference; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pdf_selector);
    checkconnection();
    Intent j = getIntent();
    u = j.getStringExtra("URI");
    t = j.getStringExtra("CAT");
    uri = t + "/" + u + ".pdf";
    pdfview = (PDFView) findViewById(R.id.pdfview);
    File file = new File(Environment.getExternalStorageDirectory().toString() + "/College Doc/"+t+"/" + u + ".pdf");
    if (file.exists()) {

        pdfview.fromFile(file).load();
    }
    else if(!running)
    {
        int su=0;
        Toast.makeText(PdfSelector.this, "No Internet... Downloading not possible", Toast.LENGTH_SHORT).show();
        Intent i = new Intent(PdfSelector.this, Subjects.class);
        i.putExtra ("SU" ,su);
        startActivity(i);
        finish();
    }
    else {
            check=false;
        FirebaseStorage storage = FirebaseStorage.getInstance();
        StorageReference storageRef = storage.getReference();
        final StorageReference pdfdownload = storageRef.child(uri);
        pdfdownload.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
            @Override
            public void onSuccess(Uri uric) {
                // Got the download URL for 'users/me/profile.png'
                pdfdownload.getFile(uric);
                //checkconnection();
                //pdfview.loadPages();
                //temp = (TextView) findViewById(R.id.temp);
                //temp.setText(uric.toString());
                Uri ur = Uri.parse(uric.toString());
                file_url = uric.toString();
                new DownloadFileFromURL().execute(file_url);
                // startActivity(new Intent(PdfSelector.this,Topics.class));
        /*Intent webIntent = new Intent(Intent.ACTION_VIEW, ur);
        if (webIntent.resolveActivity(getPackageManager()) != null){
            startActivity(webIntent);
        }*/

            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception exception) {
                // Handle any errors
                //startActivity(new Intent(PdfSelector.this,Subjects.class));
                check=true;
                if(running)
                    Toast.makeText(PdfSelector.this, "File Not Exist", Toast.LENGTH_SHORT).show();
                else
                    Toast.makeText(PdfSelector.this, "downloading failed", Toast.LENGTH_SHORT).show();
                checkconnection();
                finish();
            }
        });
    }
}
 
开发者ID:Shobhit-pandey,项目名称:CollegeDoc,代码行数:65,代码来源:PdfSelector.java

示例10: uploadReport

import com.google.firebase.storage.StorageReference; //导入方法依赖的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();

            }
        });


    }
 
开发者ID:webianks,项目名称:Crimson,代码行数:54,代码来源:SaveReports.java

示例11: removeImage

import com.google.firebase.storage.StorageReference; //导入方法依赖的package包/类
public Task<Void> removeImage(String imageTitle) {
    StorageReference storageRef = storage.getReferenceFromUrl("gs://socialcomponents.appspot.com");
    StorageReference desertRef = storageRef.child("images/" + imageTitle);

    return desertRef.delete();
}
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:7,代码来源:DatabaseHelper.java

示例12: includesForCreateReference

import com.google.firebase.storage.StorageReference; //导入方法依赖的package包/类
private void includesForCreateReference() {
    FirebaseStorage storage = FirebaseStorage.getInstance();

    // ## Create a Reference

    // [START create_storage_reference]
    // Create a storage reference from our app
    StorageReference storageRef = storage.getReference();
    // [END create_storage_reference]

    // [START create_child_reference]
    // Create a child reference
    // imagesRef now points to "images"
    StorageReference imagesRef = storageRef.child("images");

    // Child references can also take paths
    // spaceRef now points to "images/space.jpg
    // imagesRef still points to "images"
    StorageReference spaceRef = storageRef.child("images/space.jpg");
    // [END create_child_reference]

    // ## Navigate with References

    // [START navigate_references]
    // getParent allows us to move our reference to a parent node
    // imagesRef now points to 'images'
    imagesRef = spaceRef.getParent();

    // getRoot allows us to move all the way back to the top of our bucket
    // rootRef now points to the root
    StorageReference rootRef = spaceRef.getRoot();
    // [END navigate_references]

    // [START chain_navigation]
    // References can be chained together multiple times
    // earthRef points to 'images/earth.jpg'
    StorageReference earthRef = spaceRef.getParent().child("earth.jpg");

    // nullRef is null, since the parent of root is null
    StorageReference nullRef = spaceRef.getRoot().getParent();
    // [END chain_navigation]

    // ## Reference Properties

    // [START reference_properties]
    // Reference's path is: "images/space.jpg"
    // This is analogous to a file path on disk
    spaceRef.getPath();

    // Reference's name is the last segment of the full path: "space.jpg"
    // This is analogous to the file name
    spaceRef.getName();

    // Reference's bucket is the name of the storage bucket that the files are stored in
    spaceRef.getBucket();
    // [END reference_properties]

    // ## Full Example

    // [START reference_full_example]
    // Points to the root reference
    storageRef = storage.getReference();

    // Points to "images"
    imagesRef = storageRef.child("images");

    // Points to "images/space.jpg"
    // Note that you can use variables to create child values
    String fileName = "space.jpg";
    spaceRef = imagesRef.child(fileName);

    // File path is "images/space.jpg"
    String path = spaceRef.getPath();

    // File name is "space.jpg"
    String name = spaceRef.getName();

    // Points to "images"
    imagesRef = spaceRef.getParent();
    // [END reference_full_example]
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:82,代码来源:StorageActivity.java


注:本文中的com.google.firebase.storage.StorageReference.child方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。