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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:37:13+00:00 2026-06-06T19:37:13+00:00

So you think it would be easy to find a direct example of POST

  • 0

So you think it would be easy to find a direct example of POST information to ASIFormDataRequest, but I havent found a 1:1 in these formats. Here’s the POST request I want to send:

POST /fileXfer HTTP/1.1
Content-Type: multipart/form-data; boundary=AaB03x
Content-Length: 200
AppID:myID
TransferID:abcd1234

-- AaB03x
Content-Disposition: form-data; name="data"; filename="xxx"
Content-Type: application/octet-stream
Content-Length: 100

... contents of file ...

--AaB03x--

EDIT:

Turns out my problems were more with the server receiving the data. But this is what I ended up with!

NSURL *url = [NSURL URLWithString:@"http://IP:PORT/fileXfer"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostFormat:ASIMultipartFormDataPostFormat];

//Sets headers of POST
[request addRequestHeader:@"X-Application-Id" value:@"myID"];
[request addRequestHeader:@"X-Transfer-Id" value:@"abcd1234"];

//Sets data
NSData *fileData = [NSData dataWithContentsOfFile:kEncryptedFilePath];
[request setData:fileData withFileName:@"xxx" andContentType:@"application/octet-stream" forKey:@"data"];

[request setDelegate:self];
[request startAsynchronous];

I also added the following line to ASIFormDataRequest’s buildMultipartFormDataPostBody where Content-Disposition and Content-Type are set:

[self appendPostString:[NSString stringWithFormat:@"Content-Length: %lu\r\n\r\n", [data length]]];`

I’m not sure if there’s an easier way to add that line directly from the request, but out of the things I tried, this seemed to be the one that worked.

  • 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-06T19:37:13+00:00Added an answer on June 6, 2026 at 7:37 pm

    Rather than building the HTTP body manually, which may lead to errors, you should better use the methods provided by ASIFormDataRequest.

    NSURL *url = [NSURL URLWithString:@"http://IP:PORT/fileXfer"];
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
    
    [request addRequestHeader:@"X-Application-Id" value:@"myID"];
    [request addRequestHeader:@"X-Transfer-Id" value:@"abcd1234"];
    
    [request setData:[self fileData] withFileName:@"xxx" andContentType:@"application/octet-stream" forKey:@"data"];
    
    [request setDelegate:self];
    [request startAsynchronous];
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You would think this would be super-easy to find, but I can't seem to.
You would think it would be easy to find out what 1 means, but
Sorry if this is duplicate,I would think it would be but couldn't find anything.
I find myself stuck in something I think would be really easy to solve.
You would think that launching a bat file from Java would be an easy
I thought this would be easy. The Google makes me think otherwise. What I
I would have thought that this would be an easy thing to do, but
The following code is an example of what I think would qualify as pseudocode,
I could never think it would be even challenging but is there any function
My problem is one that you would think is quite common, but I haven't

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.