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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:36:18+00:00 2026-06-08T14:36:18+00:00

I currently am uploading files via HTTP Post, using [body appendData: [NSData dataWithData:data]]; where

  • 0

I currently am uploading files via HTTP Post, using [body appendData: [NSData dataWithData:data]]; where data is my NSMutableData representation of the file.

// Set content type to be form data
NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];

// Set content type to be form data
NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];

// Set up web request with HTTP post headers for 1 form field which is the image
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"userfile\"; filename=\".jpg\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding: NSUTF8StringEncoding]];
[body appendData: [NSData dataWithData:data]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding: NSUTF8StringEncoding]];

// Set the body
[request setHTTPBody: body];

Due to memory limitations, I have read that its best to upload using setHTTPBodyStream and passing in the location of the file on disk – how would I go about setting other attributes such as the content disposition using this method?

  • 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-08T14:36:22+00:00Added an answer on June 8, 2026 at 2:36 pm

    You have to prepare a file containing the entire HTML request body, including the multipart boundaries, the content type and disposition, and use that for setHTTPBodyStream.

    There are alternatives (subclassing NSInputStream, which seems to be a bit tricky, and 3rd party libraries such as ASIHTTPRequest). This post provides more information and links.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently looking in to some file uploading using Java Server Faces. I've
Im currently uploading data to MS SQL server via SQLBulkCopy and Transactions. I would
I am currently uploading files in ActionScript 3 using the upload() method of the
I'm using blueimp JQuery file upload script to fancy the uploading of files. You
I'm uploading a fairly large file with urllib2 to a server-side script via POST.
I am currently having issues uploading files to amazon S3 while using paperclip. It
I'm currently uploading a single file successfully with the following form: <html> <body> <form
I am using a multiple file upload scenario based on blueimp ( http://blueimp.github.com/jQuery-File-Upload )
I am currently working with multiple php image uploading but using this SITE I
Currently, I am uploading PDF files, and images from my MVC web application to

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.