react-native-photos-framework
                                
                                
                                
                                    react-native-photos-framework copied to clipboard
                            
                            
                            
                        Unable to save video asset into album
I'm trying to save a video into a specific album, I use similar structure for the images and that works but the videos do not get saved into a album. This is on ios. I get the uri and the album but
if(Platform.OS === 'ios') {
        this.camera
          .capture({ mode: Camera.constants.CaptureMode.video })
          .then(
            (data) => {
              const album = this.state.albumUsed;
              return RNPhotosFramework.createAssets({
                album: album,
                videos: [{
                  uri: data.path
                }],
              })
            .then(() => console.log('Video taken and saved in a album'))})
          .catch((err) => console.log('Video taken error log:' + err));
        this.setState({
          isRecording: true,
        });
In the createasset code below
createAssets(params, onProgress) {
   const images = params.images;
   const videos = params.videos !== undefined ? params.videos.map(videoPropsResolver) : params.videos;
   let media = [];
   if (images && images.length) {
     media = media.concat(images.map(image => ({
       type: 'image',
       source: image
     })));
   }
   if (videos && videos.length) {
     media = media.concat(videos.map(video => ({
       type: 'video',
       source: video
     })));
   }
   const {
     args,
     unsubscribe
   } = this.withUniqueEventListener('onCreateAssetsProgress', {
       media: media,
       albumLocalIdentifier: params.album ?
         params.album.localIdentifier : undefined,
       includeMetadata: params.includeMetadata
     }, onProgress);
   return RNPFManager
     .createAssets(args)
     .then((result) => {
       unsubscribe && this.nativeEventEmitter.removeListener(unsubscribe);
       return result
         .assets
         .map(this.createJsAsset);
     });
 }
I get the media as
isAsset : true
isNetwork:false
type:undefined
uri:"assets-library://asset/asset.mov?id=A226D7D9-07FD-4583-B651-DA2EFBD585C4&ext=mov"
and videos as
isAsset:true
isNetwork:false
type:undefined
uri:"assets-library://asset/asset.mov?id=A226D7D9-07FD-4583-B651-DA2EFBD585C4&ext=mov"
then when runnnig result become com up with assets as empty
result
:
assets:Array(0)
length:0
Am I not using this correctly or should I rather be using RCTCameraRollRNPhotosFrameworkManager.createVideoAsset(videoWithUriProp); and then album.addAssetToAlbum(asset).then((status) => {}); ?
Just in case someone is having troubles here is how I made it work
Get all albums with the name. If there are not then create and save the new asset in it, otherwise take the first one (hence its an array) and save the media in it.
For images just change the videos params in createAssets to videos
saveToCameraRollVideo = (url) =>  
    RNPhotosFramework.getAlbumsByTitle('TestAlbum').then((response) => {
      const {albums} = response;
      if(albums.length ===0) {
      return RNPhotosFramework.createAlbum('TestAlbum').then((album) => {
        return  RNPhotosFramework.createAssets({
          album: album,
          videos: [{
            uri: url
          }]
        })
     
      });
    } else {
      return  RNPhotosFramework.createAssets({
        album: albums[0],
        videos: [{
          uri: url
        }]
      })
    }
  });