Java Code Examples for com.google.firebase.storage.UploadTask#TaskSnapshot
The following examples show how to use
com.google.firebase.storage.UploadTask#TaskSnapshot .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 6 votes |
@Test public void testPutStreamWithMetadata_notSuccessful() { mockNotSuccessfulResultForTask(mockUploadTask, new IllegalStateException()); when(mockStorageReference.putStream(mockInputStream, mockStorageMetadata)).thenReturn( mockUploadTask); TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.putStream(mockStorageReference, mockInputStream, mockStorageMetadata) .subscribe(obs); verifyAddOnCompleteListenerForTask(mockUploadTask); callOnComplete(mockUploadTask); obs.dispose(); callOnComplete(mockUploadTask); obs.assertError(IllegalStateException.class); obs.assertNoValues(); }
Example 2
Source File: FirestackStorage.java From react-native-firestack with MIT License | 6 votes |
private WritableMap getDownloadData(final UploadTask.TaskSnapshot taskSnapshot) { Uri downloadUrl = taskSnapshot.getDownloadUrl(); StorageMetadata d = taskSnapshot.getMetadata(); WritableMap resp = Arguments.createMap(); resp.putString("downloadUrl", downloadUrl.toString()); resp.putString("fullPath", d.getPath()); resp.putString("bucket", d.getBucket()); resp.putString("name", d.getName()); WritableMap metadataObj = Arguments.createMap(); metadataObj.putString("cacheControl", d.getCacheControl()); metadataObj.putString("contentDisposition", d.getContentDisposition()); metadataObj.putString("contentType", d.getContentType()); resp.putMap("metadata", metadataObj); return resp; }
Example 3
Source File: RxFirebaseStorageTests.java From RxFirebase with Apache License 2.0 | 6 votes |
@Test public void putStreamMetadata() { TestSubscriber<UploadTask.TaskSnapshot> testSubscriber = new TestSubscriber<>(); RxFirebaseStorage.putStream(mockStorageRef, stream, metadata) .subscribeOn(Schedulers.immediate()) .subscribe(testSubscriber); testOnSuccessListener.getValue().onSuccess(uploadSnapshot); verify(mockStorageRef).putStream(stream, metadata); testSubscriber.assertNoErrors(); testSubscriber.assertValueCount(1); testSubscriber.assertReceivedOnNext(Collections.singletonList(uploadSnapshot)); testSubscriber.assertNotCompleted(); testSubscriber.unsubscribe(); }
Example 4
Source File: RxFirebaseStorageTests.java From RxFirebase with Apache License 2.0 | 6 votes |
@Test public void putStream() { TestSubscriber<UploadTask.TaskSnapshot> testSubscriber = new TestSubscriber<>(); RxFirebaseStorage.putStream(mockStorageRef, stream) .subscribeOn(Schedulers.immediate()) .subscribe(testSubscriber); testOnSuccessListener.getValue().onSuccess(uploadSnapshot); verify(mockStorageRef).putStream(stream); testSubscriber.assertNoErrors(); testSubscriber.assertValueCount(1); testSubscriber.assertReceivedOnNext(Collections.singletonList(uploadSnapshot)); testSubscriber.assertNotCompleted(); testSubscriber.unsubscribe(); }
Example 5
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 6 votes |
@Test public void testPutBytes() { mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot); when(mockStorageReference.putBytes(new byte[] { 1, 2, 3 })).thenReturn(mockUploadTask); when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L); when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L); TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.putBytes(mockStorageReference, new byte[] { 1, 2, 3 }).subscribe(obs); verifyAddOnCompleteListenerForTask(mockUploadTask); callOnComplete(mockUploadTask); obs.dispose(); callOnComplete(mockUploadTask); obs.assertNoErrors(); obs.assertComplete(); obs.assertValue(new Predicate<UploadTask.TaskSnapshot>() { @Override public boolean test(UploadTask.TaskSnapshot taskSnapshot) throws Exception { return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount() && taskSnapshot.getTotalByteCount() == 1000L; } }); }
Example 6
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 6 votes |
@Test public void testPutBytes_notSuccessful() { mockNotSuccessfulResultForTask(mockUploadTask, new IllegalStateException()); when(mockStorageReference.putBytes(new byte[] { 1, 2, 3 })).thenReturn(mockUploadTask); TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.putBytes(mockStorageReference, new byte[] { 1, 2, 3 }).subscribe(obs); verifyAddOnCompleteListenerForTask(mockUploadTask); callOnComplete(mockUploadTask); obs.dispose(); callOnComplete(mockUploadTask); obs.assertError(IllegalStateException.class); obs.assertNoValues(); }
Example 7
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 6 votes |
@Test public void testPutStream_notSuccessful() { mockNotSuccessfulResultForTask(mockUploadTask, new IllegalStateException()); when(mockStorageReference.putStream(mockInputStream)).thenReturn(mockUploadTask); TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.putStream(mockStorageReference, mockInputStream).subscribe(obs); verifyAddOnCompleteListenerForTask(mockUploadTask); callOnComplete(mockUploadTask); obs.dispose(); callOnComplete(mockUploadTask); obs.assertError(IllegalStateException.class); obs.assertNoValues(); }
Example 8
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 6 votes |
@Test public void testPutStream() { mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot); when(mockStorageReference.putStream(mockInputStream)).thenReturn(mockUploadTask); when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L); when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L); TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.putStream(mockStorageReference, mockInputStream).subscribe(obs); verifyAddOnCompleteListenerForTask(mockUploadTask); callOnComplete(mockUploadTask); obs.dispose(); callOnComplete(mockUploadTask); obs.assertNoErrors(); obs.assertComplete(); obs.assertValue(new Predicate<UploadTask.TaskSnapshot>() { @Override public boolean test(UploadTask.TaskSnapshot taskSnapshot) throws Exception { return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount() && taskSnapshot.getTotalByteCount() == 1000L; } }); }
Example 9
Source File: RxFirebaseStorageTests.java From RxFirebase with Apache License 2.0 | 6 votes |
@Test public void putBytes() { TestSubscriber<UploadTask.TaskSnapshot> testSubscriber = new TestSubscriber<>(); RxFirebaseStorage.putBytes(mockStorageRef, bytes) .subscribeOn(Schedulers.immediate()) .subscribe(testSubscriber); testOnSuccessListener.getValue().onSuccess(uploadSnapshot); verify(mockStorageRef).putBytes(bytes); testSubscriber.assertNoErrors(); testSubscriber.assertValueCount(1); testSubscriber.assertReceivedOnNext(Collections.singletonList(uploadSnapshot)); testSubscriber.assertNotCompleted(); testSubscriber.unsubscribe(); }
Example 10
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 6 votes |
@Test public void testPutBytesWithMetadata_notSuccessful() { mockNotSuccessfulResultForTask(mockUploadTask, new IllegalStateException()); when(mockStorageReference.putBytes(new byte[] { 1, 2, 3 }, mockStorageMetadata)).thenReturn( mockUploadTask); TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.putBytes(mockStorageReference, new byte[] { 1, 2, 3 }, mockStorageMetadata) .subscribe(obs); verifyAddOnCompleteListenerForTask(mockUploadTask); callOnComplete(mockUploadTask); obs.dispose(); callOnComplete(mockUploadTask); obs.assertError(IllegalStateException.class); obs.assertNoValues(); }
Example 11
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 6 votes |
@Test public void testPutFileWithMetadataAndUri_notSuccessful() { mockNotSuccessfulResultForTask(mockUploadTask, new IllegalStateException()); when(mockStorageReference.putFile(mockUri, mockStorageMetadata, mockUri)).thenReturn( mockUploadTask); TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.putFile(mockStorageReference, mockUri, mockStorageMetadata, mockUri) .subscribe(obs); verifyAddOnCompleteListenerForTask(mockUploadTask); callOnComplete(mockUploadTask); obs.dispose(); callOnComplete(mockUploadTask); obs.assertError(IllegalStateException.class); obs.assertNoValues(); }
Example 12
Source File: RxFirebaseStorage.java From RxFirebase with Apache License 2.0 | 5 votes |
@NonNull public static Observable<UploadTask.TaskSnapshot> putStream(@NonNull final StorageReference storageRef, @NonNull final InputStream stream, @NonNull final StorageMetadata metadata) { return Observable.unsafeCreate(new Observable.OnSubscribe<UploadTask.TaskSnapshot>() { @Override public void call(final Subscriber<? super UploadTask.TaskSnapshot> subscriber) { RxTask.assignOnTask(subscriber, storageRef.putStream(stream, metadata)); } }); }
Example 13
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 5 votes |
@Test public void testPutBytesWithMetadata() { mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot); when(mockStorageReference.putBytes(new byte[] { 1, 2, 3 }, mockStorageMetadata)).thenReturn( mockUploadTask); when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L); when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L); TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.putBytes(mockStorageReference, new byte[] { 1, 2, 3 }, mockStorageMetadata) .subscribe(obs); verifyAddOnCompleteListenerForTask(mockUploadTask); callOnComplete(mockUploadTask); obs.dispose(); callOnComplete(mockUploadTask); obs.assertNoErrors(); obs.assertComplete(); obs.assertValue(new Predicate<UploadTask.TaskSnapshot>() { @Override public boolean test(UploadTask.TaskSnapshot taskSnapshot) throws Exception { return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount() && taskSnapshot.getTotalByteCount() == 1000L; } }); }
Example 14
Source File: RxFirebaseStorage.java From RxFirebase with Apache License 2.0 | 5 votes |
@NonNull public static Observable<UploadTask.TaskSnapshot> putFile(@NonNull final StorageReference storageRef, @NonNull final Uri uri) { return Observable.unsafeCreate(new Observable.OnSubscribe<UploadTask.TaskSnapshot>() { @Override public void call(final Subscriber<? super UploadTask.TaskSnapshot> subscriber) { RxTask.assignOnTask(subscriber, storageRef.putFile(uri)); } }); }
Example 15
Source File: RxFirebaseStorage.java From RxFirebase with Apache License 2.0 | 5 votes |
@NonNull public static Observable<UploadTask.TaskSnapshot> putBytes(@NonNull final StorageReference storageRef, @NonNull final byte[] bytes, @NonNull final StorageMetadata metadata) { return Observable.unsafeCreate(new Observable.OnSubscribe<UploadTask.TaskSnapshot>() { @Override public void call(final Subscriber<? super UploadTask.TaskSnapshot> subscriber) { RxTask.assignOnTask(subscriber, storageRef.putBytes(bytes, metadata)); } }); }
Example 16
Source File: RxFirebaseStorage.java From rxfirebase with Apache License 2.0 | 5 votes |
/** * @see StorageReference#putStream(InputStream) */ @CheckReturnValue @NonNull public static Single<UploadTask.TaskSnapshot> putStream( @NonNull final StorageReference ref, @NonNull final InputStream inputStream) { return RxTask.single(new Callable<Task<UploadTask.TaskSnapshot>>() { @Override public Task<UploadTask.TaskSnapshot> call() throws Exception { return ref.putStream(inputStream); } }); }
Example 17
Source File: RxFirebaseStorage.java From rxfirebase with Apache License 2.0 | 5 votes |
/** * @see StorageReference#putBytes(byte[]) */ @CheckReturnValue @NonNull public static Single<UploadTask.TaskSnapshot> putBytes(@NonNull final StorageReference ref, @NonNull final byte[] bytes) { return RxTask.single(new Callable<Task<UploadTask.TaskSnapshot>>() { @Override public Task<UploadTask.TaskSnapshot> call() throws Exception { return ref.putBytes(bytes); } }); }
Example 18
Source File: RxFirebaseStorage.java From rxfirebase with Apache License 2.0 | 5 votes |
/** * @see StorageReference#putBytes(byte[], StorageMetadata) */ @CheckReturnValue @NonNull public static Single<UploadTask.TaskSnapshot> putBytes( @NonNull final StorageReference ref, @NonNull final byte[] bytes, @NonNull final StorageMetadata storageMetadata) { return RxTask.single(new Callable<Task<UploadTask.TaskSnapshot>>() { @Override public Task<UploadTask.TaskSnapshot> call() throws Exception { return ref.putBytes(bytes, storageMetadata); } }); }
Example 19
Source File: RxFirebaseStorage.java From rxfirebase with Apache License 2.0 | 5 votes |
/** * @see StorageReference#putFile(Uri) */ @CheckReturnValue @NonNull public static Single<UploadTask.TaskSnapshot> putFile(@NonNull final StorageReference ref, @NonNull final Uri uri) { return RxTask.single(new Callable<Task<UploadTask.TaskSnapshot>>() { @Override public Task<UploadTask.TaskSnapshot> call() throws Exception { return ref.putFile(uri); } }); }
Example 20
Source File: RxFirebaseStorage.java From rxfirebase with Apache License 2.0 | 5 votes |
/** * @see StorageReference#putFile(Uri, StorageMetadata) */ @CheckReturnValue @NonNull public static Single<UploadTask.TaskSnapshot> putFile( @NonNull final StorageReference ref, @NonNull final Uri uri, @NonNull final StorageMetadata storageMetadata) { return RxTask.single(new Callable<Task<UploadTask.TaskSnapshot>>() { @Override public Task<UploadTask.TaskSnapshot> call() throws Exception { return ref.putFile(uri, storageMetadata); } }); }