iosvideosavealassetslibraryphoto-gallery

Save Video to specific folder


I'm saving a video to my PhotosAlbum, using this code:

    ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
    [assetLibrary writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:videoPath] completionBlock:^(NSURL *assetURL, NSError *error)
    {
         NSError *removeError = nil;
         [[NSFileManager defaultManager] removeItemAtURL:[NSURL URLWithString:videoPath] error:&removeError];
    });

The video goes to the folder Videos but i want it to go to a specific folder with the name of the app. How can i accomplish this?


Solution

  • like this

     ALAssetsLibrary* assetLibrary = [[ALAssetsLibrary alloc] init];
     [assetLibrary writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:@""] completionBlock:^(NSURL *assetURL, NSError *error) {
        [assetLibrary addAssetURL:[NSURL URLWithString:@""]  toAlbum:@"" completion:^(NSURL *assetURL, NSError *error) {
        NSError* removeError = nil;
            [[NSFileManager defaultManager] removeItemAtURL:[NSURL URLWithString:@""] error:&removeError];
        } failure:^(NSError *error) {
            NSLog(@"%@", error);
        }];
    }];