Question

I am trying to access iPhone's photo album photo images through ALAssetsLibrary and upload(send) the images to my server. I am being successful accessing the photo album and get the asset URL of each images, via the following code:

    - (void)viewDidLoad
{
    [super viewDidLoad];


    void (^assetEnumerator)(struct ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
        if(result != NULL) {
            NSLog(@"See Asset: %@", result);
            [assets addObject:result];
            // Here storing the asset's image URL's in NSMutable array urlStoreArr
            NSURL *url = [[result defaultRepresentation] url];
            [urlStoreArr addObject:url]; 
        }
    };

    void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) =  ^(ALAssetsGroup *group, BOOL *stop) 
    {

        if(group != nil) {
            [group enumerateAssetsUsingBlock:assetEnumerator];
        }
        [self.activity stopAnimating];
        [self.activity setHidden:YES];
    };
    assets = [[NSMutableArray alloc] init];
    library = [[ALAssetsLibrary alloc] init];
    [library enumerateGroupsWithTypes:ALAssetsGroupAlbum
                           usingBlock:assetGroupEnumerator
                         failureBlock: ^(NSError *error) {
                             NSLog(@"Failure");
                         }];

    urlStoreArr = [[NSMutableArray alloc] init];
}

    -(void) UploadImagesToServer
{

for (int i=0; i<[urlStoreArr count]; i++)

{

       // To get the each image URL here...

        NSString *str = [urlStoreArr objectAtIndex:i];
        NSLog(@"str: %@",str);

        // Need to upload the images to my server..

    }


}

I want to upload the images which i got from the device asset's URL to my server. Could someone please advise how can i program it for sending the images to the server using this case?

Thank you!

Was it helpful?

Solution

you could use the below SO post code for uploading images to server.

How can I upload a photo to a server with the iPhone?

upload image from iphone to the server folder

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top