how to send image in messaging xmpp framework? - ios

I'm sending only text, but I don't know how to send image/url, videos and integrate that in the chat application in iOS using XMPP.
I have refer so many questions but I want to send image using XEP-0363
I refer so many demo like monal app but any demo can't clear anything.
so
Please help me.

There are a few ways to send images, one way is to create an API, and create a function for uploading images. So when you want to send an image, you can first call your API function, which will upload the image and then return the URL of the image. You can then send the URL in the <message> stanza, possibly in your own custom tags.
For example,
<message to=""...>
<image>http://example.com/myimg.jpg</image>
</message>
Of course it will then be up to the client to download the image.
Another way to do it is to convert the image to a base64 string, and send the base64 string in the message stanza. However I actually do not recommend doing so, as the base64 string can be extremely large, and sending large packets through xmpp isn't a good idea. Particularly if you are in a group chat with a lot of users, in which case it will have to send the large packet to many users, wasting up valuable bandwidth, as well as server space for any offline-stored messages.
You could of course use XEP-0363 as mentioned, but you just need to make sure your XMPP server supports it.

Related

Posting form-data and binary data through AWS API Gateway

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!!

Send large size data with Rails

I need to send to the customers a raw emails via my rails app.
When they click a link, a new page must open and they need to be able to see the source code of an email. I have a lot of cases where there are emails really big (even 40/50 mb), and it takes a lot of time to server to send it.
E.G.
I have an email with 3 attachments, the total size is 30mb. My
controller method it takes 700 ms to process it and to retrieve the
raw source from imap server, but in the broswer, it takes up to 5
seconds. (2.5 to the first byte, 2.5 to download it).
Right now I just send the string with the render method. Is there a better way? where I am losing all that time?
To be more clear:
With the word 'send' I mean when the server has to 'send' the source code to the browser so the suer can visualize it
What about storing attachments on your server and include in email only links to those attachments? This way your emails will be blazingly fast and clients may download attachments separately. If you don't want to store files on your server, you may use Amazon S3 or some other cloud storage (there are many in these days).
To ease file uploading, I'd recommend you carrierwave library, Amazon S3 integration goes from the box.
I would suggest you to use Delayed Job: https://github.com/collectiveidea/delayed_job or Sidkiq: https://github.com/mperham/sidekiq
When the job is in processing state, you can mark that email as Sending.... and once the background job is completed you can mark it as Sent
Hope this helps
I think you could benefit from looking into solutions for HTTP streaming, which would allow you to start sending data while still processing the request.
This is difficult with Rack based servers, so Rails might have some issues with this approach.
Another approach is to try and split the raw source into chunks and request each chunk using Ajax.
This will allow your app to be more responsive and offer a better user experience. This is also known as a perceived performance approach, since the user experiences the app as more responsive even if it takes the same amount of time to load.
If I were trying to resolve the issue, I would look into an Ajax solution that would allow me to leverage IMAP's partial fetch feature, referenced in it's RFC.
It's possible to write a simple server side API that fetches a part of an email or returns a signal when there is no more to download and than use Javascript to request the data from the server until the 'no more data' return value is received.
This would allow you to display the downloaded data as it's being received.

Can CDNs handle base64 encoded data?

I'm trying to make an app where I take pictures from users add them to a canvas, draw stuff in them, then convert them to a base64 string and upload them.
For this purpose I'm considering the possibility to use a cdn but can't find information on what I can upload to them and how the client side uploading works. I'd like to be able to send the image as base64 and the name to be given to the file, so that when it arrives to the origin cdn, the base64 image is decoded and saved under the specified name (which I will add to the database on the server).Is this possible?Can I have some kind of save.php file on the origin cdn where I write my logic to save the file and to which I'll send XHR requests? Or how this whole thing work?I know this question may sound trivial but I'm looking for it for hours and still didn't find anything which explains in detail how the client side uploading work for CDNs.
CDNs usually do not provide such uploading service for client side, so you can not do it in this way.

Display multiple objects from server

I am making an iOS app that will display images, videos, and textual information that I provide.
this information needs to be updated and refreshed as the user requests, time interval, and when the user opens the app. Not hardcoded and changed on app store updates.
How would i go about doing this?
Do I need to create an online web server that I pull the information from?
If so how would I go about creating a server?
Could anyone point me in the correct direction?
yeah you have to use web Services. that means you have to create one server & from that server you can send images,text as you required without making hardcoded. you just have to pull the value from web service.
images,text all this can be send through xml & you have to accept that xml & have to parse it
You can install an Apache server on your MacOS, read read this:
http://osxdaily.com/2012/09/02/start-apache-web-server-mac-os-x/
I ended up using parse which has excellent mobile support. And is free until you receive a certain amount of traction. I recommend it!

EBAY - Sending a file via http post?

I've a file I want to send to the ebay system to support the LMS.
All the samples I've found include the use of the API, but the environment I'm working in doesn't have the ability to use it (the api).
So I'm forced to send the file with an HTTP post. But the doc's seem lacking.
Has anyone constructed/found an example of a HTTP post that will send a given file.
EDIT:
Oh.. what I see in the samples I have found is an area that seems it's supposed to have the data, but in the sample, there's nothing I'd consider real data.
Are you talking about the file transfer service or the bulk upload service? Don't you just generate an xml document and post the url like in this example:
http://developer.ebay.com/DevZone/file-transfer/CallRef/uploadFile.html#Samples

Resources