Getting the progress of the sent data through Zend Rest service - zend-framework

I have the following situation. We are using Zend Framework to create a web application that is communicating with it's database through REST services.
The problem I'm facing is that when a user tries to upload a big video file for example, the service is taking some time (sometimes a few minutes) to receive the request (which is also sending the video file encoded with base64_encode PHP function.) and returns the response for successful save or error.
My idea is to track how much of the data is sent and show the user a JS progress bar, which will be useful in these cases.
Does anyone have an idea, how I can track how much of the data is sent through the service and based on this I'll be able to show a progress bar?

Zend provides progress bar functionalities that might be paired with some javascript/jquery client.
You will easily find some example implementations like this one:
https://github.com/marcinwol/zfupload
However I don't think that REST services are the best solution for uploading videos as base64 encoding will make files bigger and slower to upload.
Check out Zend_File_Transfer that might be better suited to your needs:
http://framework.zend.com/manual/1.12/en/zend.file.transfer.introduction.html

Related

Flex mobile project for IOS, server side proxy

I am trying to write an iphone app that loads a video from an inbuilt web server running off a camera (connect to iphone via wifi).
I am using flash builder / flex mobile project - not particularly familiar but finding it easier to understand than xcode !!
The files from the camera have the wrong file extension so will not play on the ios video app, can I set up a server side proxy in flex mobile and use this to alter the file extension and then pass this link to the ios video app ?
If so any help anybody could give me ( examples etc) would be really grateful received , I have been trying to get round this problem for a couple of weeks .
Cheers
Toby
I can explain, conceptually, what a server side proxy would do in this case. Let's say you are retrieving a URL, like this:
http://myserver.com/somethingSomething/DarkSide/
to retrieve a video stream from the server. You say it won't be played because there is no file extension; so you have to, in essence, use a different URL with the extension. Set up 'search engine friendly' URLs on the server. And do something like this:
http://myserver.com/myProxy.cfm/streamURL/somethingSomething%5CDarkSide/Name/myProxyVid.mp4
Here is some information on how to deal with Search Engine Friendly URLs in ColdFusion. Here is some information on how to deal with Search Engine Friendly URls in PHP. I'm sure Other technologies will come up in a Google Search.
In the URL above; this is what you have:
http://myserver.com/: This is your server
myProxy.cfm: This is your server side file; that is a proxy
streamURL/somethingSomething%5CDarkSide/Name/myProxyVid.mp4: This is the query string. It consists of two name value pairs. The first is the streamURL. This is the URL you want to retrieve with your proxy. The second is just random; but as long as it ends with the file extension .mp4 the URL should be seen as an 'mp4 file'
The code behind your myProxy.cfm should be something like this, in psuedo-code:
Parse URL Query String
Retrieve Stream.
Set mimeType on return value.
Return stream data
I used a similar approach on TheFlexShow.com to track the number of people who watch our screencast on-line vs downloading it first. I also used the same approach to keep track of impressions of advertiser's banner ads. For example, the browser can't tell that this is not a JPG image:
http://www.theflexshow.com/blog/mediaDisplay.cfm?mediaid=51
Based on this, and one of your previous questions; I am not convinced this is the best solution, though. I make a lot of assumptions here. I assume that the problem with playing the file does relate to the extension and not the file data. I assume that you are not actually streaming video with an open connection on both client and server to send data back and forth.

constructing xml within ios app

I am sending a request back to the server I am communicating with, the gist of this request will have a bunch of different parameters, like user ID, request number etc.
One of the more important parts of the request is a segment of XML that im hoping to create based of a few user selections in my interface.
Then at the end i will wrap this all up and send it off to the server...
However at the moment I have no idea how to form an segment xml, I have been reading this but im not sure how it relates to what I would like to do.
any help, example code, example tutorials or anything would be really helpful.
A plist is just xml with a strict dtd; and you can use NSPropertyListSerialization to create one to send back to the server from an NSArray/NSDictionary, very easily.

In-App Notifications?

I'm trying to create functionality in my app that would allow me to release news updates (Via a server) to those using the app, similar to what is found in Doodle Jump:
http://farm8.staticflickr.com/7143/6463110847_d485681dac.jpg
Any sample code or ideas would be helpful.
You'll probably need to create an API/web service that your app calls on launch (or when entering foreground)...you could populate that with a database that just gives the entries since the last sync...or just returns some response that you've set up. The response should be JSON or XML formatted (I vote JSON) and then in your app, you call it, parse the response, and place/manipulate it however necessary
http://mobileorchard.com/tutorial-json-over-http-on-the-iphone/
There are a lot of options here. In any case you will need a web server that hosts these news postings. The route that I would take is some kind of blog site, where you can easily manage posts. Then upon launching the app you make a web service call to said blog and get the news posts. You will need to keep track locally of which posts were read by the user in order to keep the badge count correct.
You could also roll your own server, but I don't really see the point for something so simple.
Another option is a web-service such as Parse
This question is too vague for code samples as we would be essentially writing the entire solution for you in order for it to make sense.
If you have further questions into how to leverage these web services, how to load the feed, how to display it etc... Break it up across multiple questions.
There's a service doing this called Converser, if you're still looking.

iPhone live data streaming

We have an application with charts. Client wants to implement something like in forex graphs, I mean live data, updating for example each 1, 5 or 10 seconds. Could you please provide me with some theory, how would it be possible to implement, what iOs objects should I use? What should the data provider implement?
I think you are using API s to receive live data to your application. its better that APIs are using JSON format to send data. because those are easy to use. If the data receiving in XML format then its little bit hard. There is JSON class library in the internet to download. Download it and integrate it your application and after that you can use it very easily.
http://mobileorchard.com/tutorial-json-over-http-on-the-iphone/
here is a tutorial. you can refer it and its easy :)
Data for charts should locates on any server side. Create separate thread with requests or async requests to your/clients server side. This will make your requests in the background and users of your application will not be distracted by endless stop/pause during the application lifecycle. Also in the background you should parse received data from server. There are multiple available formats for this aim (JSON in prev post, for ex.). Parse data and update your charts datasource. If your use CorePlot for building charts it's pretty straightforward to refresh charts with new data - use on these CPGraph methods
-(void)reloadData; -(void)reloadDataIfNeeded;
Check NSURLConnection for asynchronous loads of a URL request. NSOperation for start you code in background.

Sending data to a server for computation

I want to create an application which will will be a webapp. I want to collect the data from the user, send it to a server where the computation will take place, and have the result displayed on the iPhone screen. The server normally takes results from a regular webpage via text fields and computes it and displays the result on the webpage. I just want the send the data via iPhone. Navigating my iPhone safari to the webpage is NOT an option, as the webpage is not optimized. So I how do I send data to the server, make it compute the results and have the results displayed on my iPhone?
Thank you.
Regards
EDIT:
I have no control over the server. Imagine my case to be as follows: The user enters a word, the word is sent by the iPhone to a Google server, the server compiles the search results and sends it back to my iPhone, and then the iPhone displays this result on the screen.Any more suggestions?
You might consider using ASIHTTPRequest/ASIFormDataRequest if you want to submit form data to your existing web page using form fields (per your description.)
In general I find ASIHTTPRequest friendlier to use than NSURLConnection / NSURLRequest.
http://allseeing-i.com/ASIHTTPRequest/
The most straightforward way is to use NSMutableURLRequest to create the GET or POST request, and then NSURLConnection to (asynchronously) send the data and receive the result. You could also use any number of third-party libraries to do the same thing.
As for the server side of things, you would have it accept a GET or POST just as you would with a web-based app, and output data in an appropriate format.
As for the output format that will be parsed by your app: With the standard classes, you can easily parse plist data and (with a little more work) XML; third-party libraries can be found to parse json and many other formats, if you so desire.