Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8874347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:41:49+00:00 2026-06-14T18:41:49+00:00

I am trying to upload a photo from my app into a web service.

  • 0

I am trying to upload a photo from my app into a web service.

The flow I am attempting to create is as follows:

  1. User takes photo with camera
  2. Photo is saved to camera roll under a custom album
  3. URL of the saved photo is given to my store
  4. Store attempts to upload the photo to a web service.

I am trying to use NSData *data = [NSData dataWithContentsOfURL:[item assetURL]] where item is a model that contains the URL concerned. But this line is not producing a data when I log it even if it produces a URL: "assets-library://asset/asset.PNG?id=28DBC0AC-21FF-4560-A9D6-5F4BCA190BDB&ext=PNG"

The code snippets are as follows:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];



    [self dismissViewControllerAnimated:YES completion:^(void){

        [library writeImageToSavedPhotosAlbum:image.CGImage orientation:image.imageOrientation completionBlock:^(NSURL* assetURL, NSError* error) {

            BCard *card = [[BCard alloc]init];

            //error handling
            if (error!=nil) {
                NSLog(@"[ERROR] - %@",error);
                return;
            }

            //add the asset to the custom photo album
            [library addAssetURL: assetURL
                         toAlbum:@"Business Cards"
             withCompletionBlock:^(NSError *error) {
                 if (error!=nil) {
                     NSLog(@"Custom Album Error: %@", [error description]);
                 }
             }];

            [card setAssetURL:assetURL];

            [[BCardStore sharedStore]addToQueue:card];
            int index = [[[BCardStore sharedStore]getQueue]count]-1;

            [[BCardStore sharedStore]uploadItemAtIndex:index withProgressBlock:nil withExitBlock:nil];

        }];
    }];


}

and

-(void)uploadItemAtIndex:(NSUInteger)index withProgressBlock:(progressBlock)pBlock withExitBlock:(exitBlock)eBlock
{
    BCard *item = [uploadQueue objectAtIndex:index];
    NSURL *url = [NSURL URLWithString:@"http://192.168.0.116:8080"];
    NSData *data = [NSData dataWithContentsOfURL:[item assetURL]];
    AFHTTPClient *httpClient = [[AFHTTPClient alloc]initWithBaseURL:url];
    numberedName = numberedName +1;
    NSString *name = [NSString stringWithFormat:@"%d",numberedName];

    NSLog(@"%@",[item assetURL]);

//upload data using AFNetworking here
}

The snippet [library addAssetUrl:NSUrl toAlbum:NSString withCompletionBlock:^(NSError *error)] came from the category I found here.

Am I really getting the right URL here or am I using dataWithContentsOfURL incorrectly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:41:50+00:00Added an answer on June 14, 2026 at 6:41 pm

    The only way is You can retrieve the UIImage from Photo-Library using ALAsset URL and convert in to NSData.

    Add ALAssetLibrary

    Import ALAssetLibrary header file

    -(void)uploadItemAtIndex:(NSUInteger)index 
           withProgressBlock:(progressBlock)pBlock 
               withExitBlock:(exitBlock)eBlock
    {  
    
        ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
        {
            ALAssetRepresentation *rep;
            if([myasset defaultRepresentation] == nil) {
                return;
            } else {
                rep = [myasset defaultRepresentation];
            }
            CGImageRef iref = [rep fullResolutionImage];
    
            dispatch_sync(dispatch_get_main_queue(), ^{
    
    
                UIImage *myImage = [UIImage imageWithCGImage:iref];            
                NSData *data = //convert the myImage to NSData
    
                BCard *item = [uploadQueue objectAtIndex:index];
                NSURL *url = [NSURL URLWithString:@"http://192.168.0.116:8080"];  
                AFHTTPClient *httpClient = [[AFHTTPClient alloc]initWithBaseURL:url];
                numberedName = numberedName +1;
                NSString *name = [NSString stringWithFormat:@"%d",numberedName];
    
    
    
                //upload data using AFNetworking here
    
    
            });//end block
    
    
        };
        ALAssetsLibraryAccessFailureBlock failureblock  = ^(NSError *myerror)
        {
            NSLog(@"Cant get image - %@",[myerror localizedDescription]);
        };
    
        NSURL *asseturl = 
            [NSURL URLWithString:[self.photoPath objectAtIndex:[arrayIndex intValue] ]];
        //using ARC , you have to declare ALAssetsLibrary as member variable 
        ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init]; 
    
        [assetslibrary assetForURL:assetURL 
                       resultBlock:resultblock
                      failureBlock:failureblock]; 
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to let the user upload an image from my facebook app
I'm trying to take a photo from my iPhone app and upload to a
I'm trying to upload a photo from android device to a php website. For
I'am developing with PhoneGap to iPhone. Trying to FileTransfer.upload(filePath, http...) a Photo from library.
I'm trying to post a photo to Facebook page from user using Facebook SDK
I have an activity that lets a user upload a photo to the web
In my iPhone app, I am trying to upload photo on facebook wall using
I am trying to upload an image from the Androids photo gallery to a
i'm trying use facebook API to upload photo in my fan page. I downloaded
I'm trying to create a controller to upload photos in my MVC4 application. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.