當前位置: 首頁>>代碼示例>>Java>>正文


Java FirebaseStorage.getReference方法代碼示例

本文整理匯總了Java中com.google.firebase.storage.FirebaseStorage.getReference方法的典型用法代碼示例。如果您正苦於以下問題:Java FirebaseStorage.getReference方法的具體用法?Java FirebaseStorage.getReference怎麽用?Java FirebaseStorage.getReference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.firebase.storage.FirebaseStorage的用法示例。


在下文中一共展示了FirebaseStorage.getReference方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: includesForDeleteFiles

import com.google.firebase.storage.FirebaseStorage; //導入方法依賴的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

示例2: includesForMetadata_delete

import com.google.firebase.storage.FirebaseStorage; //導入方法依賴的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

示例3: storageReference

import com.google.firebase.storage.FirebaseStorage; //導入方法依賴的package包/類
@Provides
@Singleton
@Named(NAME_ROOT_STORAGE)
static StorageReference storageReference(FirebaseStorage firebaseStorage) {
    return firebaseStorage.getReference();
}
 
開發者ID:Frank1234,項目名稱:FireBaseTest,代碼行數:7,代碼來源:ApplicationModule.java

示例4: onCreate

import com.google.firebase.storage.FirebaseStorage; //導入方法依賴的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

示例5: FirebaseStorageServiceImpl

import com.google.firebase.storage.FirebaseStorage; //導入方法依賴的package包/類
public FirebaseStorageServiceImpl(Context context) {
    FirebaseStorage storage = FirebaseStorage.getInstance("gs://wisebite-f7a53.appspot.com");
    this.reference = storage.getReference();
    this.userService = ServiceFactory.getUserService(context);
}
 
開發者ID:Wisebite,項目名稱:wisebite_android,代碼行數:6,代碼來源:FirebaseStorageServiceImpl.java

示例6: includesForCreateReference

import com.google.firebase.storage.FirebaseStorage; //導入方法依賴的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

示例7: FirebaseStorageService

import com.google.firebase.storage.FirebaseStorage; //導入方法依賴的package包/類
public FirebaseStorageService(FirebaseStorage firebaseStorage, FirebaseObservableListeners firebaseObservableListeners) {
    this.firebaseStorage = firebaseStorage.getReference();
    this.firebaseObservableListeners = firebaseObservableListeners;
}
 
開發者ID:marcovann,項目名稱:Firebase-Chat-Demo,代碼行數:5,代碼來源:FirebaseStorageService.java


注:本文中的com.google.firebase.storage.FirebaseStorage.getReference方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。