I am implementing an application where i have to fetch data from server through web services. I am done with web service integration where i'm getting multipart response, which contains data for music files(.mp3 or .mid), images and plain texts. I followed this stack overflow Parse multipart response for image download in ios reference.
Problem is while i am saving the data into corresponding file formate(mentioned in headers), it's became corrupted.I am using NSASCIIStringEncoding during data conversion first time and NSUTF8StringEncoding encoding to save data. I have saved the response data here in text file.
Please help me solving this problem.
thanks in advance :)
Related
I use Firebase Firestore as a backend for my iOS app. The data is stored in a document style in Firestore as usual. And I receive (read) it as JSON in my app.
Question: Does Firestore compress the data when users read it from the DB? Like gzip it? Or does it send the raw text json?
I've searched the docs for "compression" and couldn't find anything. I've, however, found this old SO post saying: "No data compression is performed on the document data by the Firestore clients or servers." Which seems odd to me, as I thought it could benefit from gzip. Is that info still valid?
I am looking at trying to create an app the takes information provided from databases from stores and transfers this data to the app (into a spreadsheet or useable data form of some kind) and then be able to use this data within the app.
This data will also need to be able to be updated.
These are the thing I need to know
How to access these servers and retrieve the data at will
How to store this data for the app to use
If someone could please direct me to a series of tutorials about this sort of thing or provide some information that I can google and find out about that would be ideal.
Thanks
You don't need to learn tutorials if you know all about HTTP and Swift well. Well, I can provide you some fast way that you can learn
For HTTP Services :
REST Web Services => Alamofire
SOAP Web Services => Handling SOAP request using NSURLSession
If you use those, I am sure that you can do HTTP Request easily.
So, as soon as you get the response data from HTTP Request, you will have to parse it, JSON or XML.
For response parsing :
JSON : Swifty JSON : which can handle JSON more easy way
XML : SWXMLHash : which can let you handle XML easy way
So, as soon as you can parse JSON or XML that you get from HTTP request, you need somewhere to store it right? You can use SQLite Database or Realm. So, you can store it and get it back anytime you need at your local devices application memory storage.
For storing and getting result data from database:
Realm Swift : Realm ORM Database : which is easy to learn and useful and quick
These are all the Info you need. Displaying the data is based on your design theory.
For further more reading :
Alamofire Beginner Guide : AppCoda
Parsing Data and Swifty JSON : HackingWithSwift
Realm swift learning its documentation
There are many tutorials around the www.google.com all you have to do is need to ask at the search box.
I'm trying to POST "mutlipart\form-data" to my EC2 instance through AWS API Gateway, but I couldn't find a way to this. There is a way to post data using "application/x-www-form-urlencoded" and Mapping Tamplate to convert it to JSON but still posting a binary data like an image file is missing I guess. Is there anything I'm missing ?
EDIT:
I have found another way:
I convert the image to base64 string then POST it as with content type "application/x-www-form-urlencoded". By this way I'm sending whole image as string. After I got the message I can convert it back to image in PHP. Only down side of this I could find is when I convert image to base64 its size gets a bit bigger. Other than that, I couldnt find any other downside. If there is could you please share with me ?
Api Gateway team here.
Binary data isn't supported at the moment, but it's on our backlog. Several customers have requested this.
Some customers have had success using the base64 util in the mapping templates which may get it working for you: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#util-template-reference
Other than that you'll have to wait for official support.
Edit
Binary support is finally here!!
I am working on an application for iOS which needs to synchronize data between multiple users and one web server.
I did some research and the best solution I found for this is working with JSON.
At the moment I have a .json file on a web server and I am able to download the data to my iphone app and parse it.
I have two problems I didn't manage to understand yet:
1. How can each iphone user write back data to the json file on the server?
2. How can I take a data table and automaticly convert it to a .json file? so the .json file on the server will be updated every few minutes or so...
I'll appreciate any help with this!
You dont send JSON file as afile to the devices, you send a JSON request, I advice to do more reading about this topic, you can start from below:
Working with JSON in iOS 5 Tutorial
enter link description How to make HTTP request from iPhone and parse JSON result
How to fetch and parse JSON by using data models
and read this SO question:
iPhone/iOS JSON parsing tutorial
How to sent JSON request in the Post method in iPhone?
How to send json data in the Http request using NSURLRequest
I am pretty new to the Restkit. I know how my restful response will be. Its not ready yet to get from the server side. Is there a way to give dummy input directly to restkit ?
We can give json text file as an input to NSUrlConnection, similarly how to do it here?
I have been able to do this is
- (RKObjectMappingResult*)mapResponseWithMappingProvider:(RKObjectMappingProvider*)mappingProvider toObject:(id)targetObject error:(NSError**)error {
in RKObjectLoader.m
where I optionally read a static json text file and replace the bodyAsString. If you look at
[self.URL description]
you can scan the URL and maybe read a test file based on the request url
How about running a simple web server which will return any output you want in JSON format?
For example, when I need to prototype an app which will use RestKit, I create a simple ruby app using sinatra web framework (few lines of code) and start it locally, and point my RestKit based app to web app (http://www.sinatrarb.com)