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 8005427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:13:44+00:00 2026-06-04T17:13:44+00:00

Right now I’m doing a huge refactory to my code and I want to

  • 0

Right now I’m doing a huge refactory to my code and I want to unify the way I’m using Restkit. I had separated ways of making RPC calls to my API server and REST calls.

REST calls where made using objectMapping and RPC calls where made with the RKClient. Besides that, I’m using blocks instead of delegates, which is great but I have some doubts about how it works.

Here is the code I had before, which worked nicely to post the object and do the mapping manually using delegates and after that is the new code using blocks that does not send the params.

//This was the old way...
- (void) upload: (KFMedia *) pic {

    RKParams* imageParams = [RKParams params];
    NSData* imageData = UIImageJPEGRepresentation(pic.image, 0.7f);
    [imageParams setData:imageData MIMEType:@"image/jpg" forParam:@"FileUpload"];

    [[RKClient sharedClient] post:@"/api/upload/" params:imageParams delegate:self]; 

}

//This is the new way I'm trying...
- (void) upload: (KFMedia *) pic onLoad:(RKObjectLoaderDidLoadObjectBlock) loadBlock onError:(RKRequestDidFailLoadWithErrorBlock)failBlock{

    RKParams* imageParams = [RKParams params];
    NSData* imageData = UIImageJPEGRepresentation(pic.image, 0.7f);
    [imageParams setData:imageData MIMEType:@"image/jpg" forParam:@"FileUpload"];

    [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/api/upload/" usingBlock:^(RKObjectLoader *loader) {

        //Trying to set params here, but it seems that I'm not sending anything :(
        loader.params = imageParams;
        loader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[KFMedia class]];
        loader.delegate = self;
        loader.onDidLoadObject = loadBlock;
        loader.onDidFailWithError = failBlock;
        loader.onDidFailLoadWithError = failBlock;
        loader.onDidLoadResponse = ^(RKResponse *response) {
            [self fireErrorBlock:failBlock onErrorInResponse:response];
        };

    }];

}

The request I’m sending has its body empty, that means that the params are not being sendend or setted properly. Any ideas on how to get this to work?

  • 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-04T17:13:46+00:00Added an answer on June 4, 2026 at 5:13 pm

    I just solved the problem. To send the extra params with loadObjectsAtResourcePath you must force a post using

    loader.method = RKRequestMethodPOST;
    

    the code is as follows:

    - (void) upload: (KFMedia *) pic onLoad:(RKObjectLoaderDidLoadObjectBlock) loadBlock onError:(RKRequestDidFailLoadWithErrorBlock)failBlock{
    
        RKParams* imageParams = [RKParams params];
        NSData* imageData = UIImageJPEGRepresentation(pic.image, 0.7f);
        [imageParams setData:imageData MIMEType:@"image/jpg" forParam:@"FileUpload"];
    
        [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/api/upload/" usingBlock:^(RKObjectLoader *loader) {
    
            loader.method = RKRequestMethodPOST; //This line solved the problem
            loader.params = imageParams;
            loader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[KFMedia class]];
            loader.delegate = self;
            loader.onDidLoadObject = loadBlock;
            loader.onDidFailWithError = failBlock;
            loader.onDidFailLoadWithError = failBlock;
            loader.onDidLoadResponse = ^(RKResponse *response) {
                [self fireErrorBlock:failBlock onErrorInResponse:response];
            };
    
        }];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now, to be sure I am getting what I want I am using
Right now I am using sqlite within a ios application, and I want to
Right now I am writing some Python code to deal with massive twitter files.
Right now I'm using the following command to compile a coffeescript file each time
Right now I'm using OleDbDataAdapter objDataReader = new OleDbDataAdapter(); objDataReader.SelectCommand = myCommand; objDataReader.Fill(myDataTable); But
Right now, I have elements with different z-index , and I want to group
Right now, I have three models Post, Comment and User (using Devise ) associated
right now i m using adobe live media encoder to stream live webcam video
Right now, I have basic code for moving the textfield above the keyboard when
Right now I'm doing this: class MyTest(Base): __tablename__ = 'mytest' id = Column(Integer, primary_key

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.