@@ -176,18 +176,40 @@ describe('upload from storage', (report, done) => {
176176 }
177177} )
178178
179- describe ( 'upload from CameraRoll' , ( report , done ) => {
180- let tmp = fs . dirs . DocumentDir + '/tmp' + Date . now ( )
181- let blob
182- CameraRoll . getPhotos ( { first : 10 } )
179+ Platform . OS === 'ios' && describe ( 'upload from CameraRoll' , ( report , done ) => {
180+
181+ CameraRoll . getPhotos ( { first : 10 } )
183182 . then ( ( resp ) => {
184183 let url = resp . edges [ 0 ] . node . image . uri
185184 console . log ( 'CameraRoll' , url )
186- return fs . cp ( url , tmp )
185+ return Blob . build ( RNFetchBlob . wrap ( url ) , { type : 'image/jpg' } )
187186 } )
188- . then ( ( ) => {
189- console . log ( 'cp' , tmp )
190- return Blob . build ( RNFetchBlob . wrap ( tmp ) , { type :'image/jpg' } )
187+ . then ( ( b ) => {
188+ blob = b
189+ console . log ( 'start upload ..' )
190+ return firebase . storage ( )
191+ . ref ( 'rnfbtest' ) . child ( `camra-roll-${ Platform . OS } -${ Date . now ( ) } .jpg` )
192+ . put ( b , { contentType : 'image/jpg' } )
193+ } )
194+ . then ( ( snapshot ) => {
195+ report ( < Assert key = "upload sucess" expect = { true } actual = { true } /> )
196+ done ( )
197+ } )
198+ } )
199+
200+
201+ Platform . OS === 'android' && describe ( 'upload from CameraRoll' , ( report , done ) => {
202+
203+ let blob
204+ RNFetchBlob . config ( {
205+ addAndroidDownloads : { useDownloadManager : true }
206+ } )
207+ . fetch ( 'GET' , `${ TEST_SERVER_URL } /public/1600k-img-dummy.jpg` )
208+ . then ( ( res ) => CameraRoll . getPhotos ( { first : 10 } ) )
209+ . then ( ( resp ) => {
210+ let url = resp . edges [ 0 ] . node . image . uri
211+ console . log ( 'CameraRoll' , url )
212+ return Blob . build ( RNFetchBlob . wrap ( url ) , { type :'image/jpg' } )
191213 } )
192214 . then ( ( b ) => {
193215 blob = b
0 commit comments