Sending base64 encode images over a socket - iphone

We currently are building a chat like social service, running on a node.js using sockets. the code is running fine but we have some strange behaviour when sending an encoded image(base64) over the line. it takes ages for the image to arrive around 1/2 minutes. This is tested localhost for both the client and the server
We can't find the issue this is the server sided code in question. the iPhone app uses the GCDAsync Library and logs everytime a write has finished. (this is almost instant) only the server is getting it a minute or two after it has been send. The image in question is 48kb
Server Partial Source
Thank you for your help. i can't seem to find the issue i hope stackoverflow can !

I was facing same issue while sending image via Sockets.
Like you I was sending base64 via sockets
What I Did, I resized my image to 150px x 150px and converted that into base64 and sent it to socket. Meanwhile I uploaded original image to server whose URL I added to base64 message. Now at receiver end, you need to convert base64 to image which is thumbnail, and you can either download large image in back ground or you can give user an option to download large images. This is how whats app and other messaging App works

Related

WEBRTC got remote scream but only video doesn't display in view(making SFU)

As the image shown, I got the remote stream from the server and I tried to attach the stream to video, but it is not displaying any video on the view.
It totally works in the local. Also, the turn/stun server works in the other app or server I created. Moreover, I can notice they are connected as chatting or any other functions are working between them.
I am trying to figure out why it is not displaying the video, but really stuck now on.
--host
--client
Is there any solution for this or any suggestion to try?
This is the picture that works in local
--host
--client
PLUS) There is no error I got in the server or in the view.
All the problem was candidate... make sure you emit the candidate to server and get back the candidate to client...

Sending emoticons from iPhone to CakePHP but received blank value

I am developing an iPhone app that would send emoticons from iPhone to server-side.
But, what the server-side received everytime is always null(or blank?).
I referred here at SO but with no help.
I also referred HTML_Emoji but it seems to be not an simple encoding or escape character issue.
Is it an issue about carrier's emoticons codes?
So, how could I receive the right emoticons in CakePHP?
Or its not an issue just in CakePHP framework but in PHP or Java or any language else?
What I am developing is the webservice(server-side), and the development of iPhone app is other partner. What sending from iPhone is no problem by theirs saying and with log output(such as \Ud83c\Udfe7) in Xcode when debugging, but I just receive them at server-side with blank value.
By the way, one message sending from our iPhone app with just plain text, it could be received correctly(received by $_POST in CakePHP);
with emoticons in the message, what php received is only plain text without emoticons in it.
Thanks.
I think what you are trying to do is send the 'image' file and have php capture that data. In order to do that you need to 'capture' the image data with something like:
$img_data = file_get_contents('php://input');
This is PHP specific if you plan on using PHP regardless of the framework. You can read more about how to capture this data here:
http://php.net/manual/en/wrappers.php.php
UPDATE
You need to store it as a blob so it will store the image data correctly.

how to upload images on the serve from the SQLite when network available

I am working on an app. witch functionality is user take photo from camera and saved on the server.if network is available otherwise it saved in locally in iPhone(via sqlite). but when network is available it take all local images from database and saved on the server. after that it delete from the server.
my problem is how to save images on the serve(when network available) when application is running on the background.
plese suggest me.
there are three questions:
1: how to upload and store a image on a webserver
2: how to send an image to the webserver
3: how to trigger uploading an image with respect to network-reachablity
1: Restful-Service or normal web-form-file-upload
2: depends on the method you choose in 1. if restful-service: binary-data in HTTP-Body; if web-form-file-upload via multipart then take a look at this so-thread
3: either just try sending: you will get an error if the iphone is not able to send data and thn try a few minutes later. Or use the Reachability-Example from Apple which is able to notify you about internet-reachability.

iPhone - Data URI's (css background images) only work when connected to WIFI

I've created a mobile web application for use by Android and iPhone devices, after testing I was happy that everything worked perfectly and so decided to try optimising it a little.
I decided I would use data uri's in my css file as all the images are small 16x16px png images.
While testing with my iPhone connected to the Internet via WiFi the images load fine, however when connecting using the mobile data connection images do not load.
Looking through the Apache error log I see that for some reason the image is being requested as a file (and is not being found), although using WiFi there are no errors...
File does not exist: /www/min/data:image, referer: http://mysite.com/login/
The CSS I am using is as follows...
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA5CAYAAAD3PEFJAAAAUUlEQVQYV4XMyw1AABQF0ePpQCNK0Ke+lCEkFmLjWRHx3dzcZCaDItV1m5GZgn0y1+M9AWfl4r2Cv/Jd+fDWN/AXgCyrqukCY6APDIEpMAeWDc7zXPFRLR43AAAAAElFTkSuQmCC");
I've tried everything I can thing of, not using css shorthand/using css shorthand, different mime types, not using Google Minify, but all to no avail. But this still does not explain why it all works perfectly over WiFi.
The Android device also works perfectly as do Firefox, Chrome and the desktop version of Safari. Also when loading the actual PNG image files (as opposed to embedding images using data URIs) the images load fine.
If anybody can shed some light on this I will be eternally grateful, most things I can work out but this has me completely stumped!
I am wondering if the carrier is blocking data URI schemes or plain does not support it. I would try to tether the laptop with a mobile connection and see if data URIs work. Hmm, but then you would not have seen the request fail on your web server logs. I also recommend seeing the request coming in to the server using wireshark and see if there is a difference in requests between the one from mobile connection vs. wifi (specifically the headers being sent in the two requests)
This is not really a solution, more of a work around...
It seems after much messing around that the only way I can find to get this to work (usin go2) is to use inline styles for css containing the data uri's.
However, my intention was to embed the images into the external stylesheet so it (and the embedded images) would become cached, embedding images into the html document itself means I cannot cache the images so they must be loaded with every request.
As always, if there is a better way I would love to hear about it.

How to asynchronously receive data into a Rails app from an iPhone app?

A large part of a project I'm working on now deals with sending certain messages, which can easily and preferably be XML, from an iPhone app to a Ruby On Rails app. The webapp will have to instantly show these messages, so reloading the page isn't really an option.
I've been unable to find any info re: creating this sort of listening process for a POST request, can anyone guide me in the right path, and perhaps shed some light on what I should be doing, if I am overlooking something?
edit: Would using sockets be smarter? The apps will be run from iPod Touches/iPads in the same wifi network.
Thanks!
What you're trying to accomplish is doable, but certainly not one of the strengths of Ruby on Rails. If you need to update messages in the browser in realtime you can use JSSockets. But you need a server backend that is able to deal with lots of persistent connections like nodejs or if you prefer to use ruby EventMachine. If you still want to receive the messages via your rails app, the flow of data would be
Rails app receives the Message (say by POSTing XML to /messages)
The rails app posts the message into a message queue. Have look at resque
The Evented server listens to the queue and posts messages to the browser
Update:
Sorry, I misread your question as the iPhone app being only the sending part. Unfortunately you can't use JSSockets on the iPhone as it comes with an Adobe Flash component for communication. However, you still have the option of using long polling or implementing the socket in Objective-C and pushing the received objects into your webview via [webview stringByEvaluatingJavascriptString].