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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:40:06+00:00 2026-05-31T03:40:06+00:00

I have a problem converting a File Blob comming from a Webservice to an

  • 0

I have a problem converting a File Blob comming from a Webservice to an NSData Object. The File Blob can be any type of file. I can request a file from a Webserver via RestKit and get the following response:

[{
   "FileBlob":    [
      65,
      108,
      108,
      111,
      99,
      46,
      32,
      83,
      /* more integer values omitted */
   ],
   "FileID": 1234567890,
   "FileName": "name.txt"
}]

I convert the Response into a Dictionary via JSONKit NSDictionary *dict = [[response bodyAsString] objectFromJSONString]; which works fine. But i cannot figure out how to convert the FileBlob into a NSData Object so that i can write it as a file onto the HDD. In case of a txt-File like in the example above i can go trough the array and convert all integer Values to chars

NSMutableString *fileString = [NSMutableString string];
for (NSNumber *value in [[dict valueForKey:@"FileBlob"] objectAtIndex:0]) {
    [fileString appendFormat:@"%c", (char)value.integerValue];
}

and then save everything to disk

NSData *data = [fileString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *file = [[paths objectAtIndex:0] stringByAppendingPathComponent:filename];        
[[NSFileManager defaultManager] createFileAtPath:file contents:data attributes:nil];

But if the file is something else like a pdf this does not work. Is there anything i can do, to convert the File Blob to an NSData Object or anything else to write the blob as a file onto the disc?

  • 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-05-31T03:40:07+00:00Added an answer on May 31, 2026 at 3:40 am

    Use NSMutableData instead:

    NSMutableData *data = [NSMutableData dataWithCapacity:blobs.count];
    
    for (NSNumber *number in blobs)
    {
        uint8_t byte = (uint8_t)[number intValue];
        [data appendBytes:&byte length:1];
    }
    
    // write data to file
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem with reading from a file, and converting content to double.
I have a problem with converting a text file from ANSI to UTF8 in
I have a problem creating a DLL file from a JAR file with IKVM
I have a scenario where I'm reading values from a file and converting it
I have a problem with importing 3D model from FBX file. Source model contains
I am new to vc++. I have a problem in converting file path to
I have some problem converting my data from an plist to objects. The plist
I have a problem converting a string binary to a decimal I was using
I have a problem while converting a string whose value is dd.mm.yyyy to DateTime
I seem to always have problems with converting data to and from XML in

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.