Browsers insert repeatedly '#10;' in base64 string on every new line? - android

I want to show on browser already received jpg images coded as Base64.
1. So I upload jpg images to my backend.
2. Then I want to show that uploaded image on the browser.
On Safari it work properly and I have following inspection:
src="data:image/jpeg;base64,_9j_4AAQSkZJRgABAQAAAQABAAD_2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH_2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH...
But on every other browser I can't see the very same image, due to the fact that the other base64 tag has repeated occurances of #10; in between the base64 as:
src="data:image/jpeg;base64,_9j_4AAQSkZJRgABAQAAAQABAAD_2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH_2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQE...
So other browsers do obviously insert a #10; whereever a new line takes place..
I make the uplod from Android Smartphones and I encode to base64 via:
Base64.encodeToString(jpgStream.toByteArray(), Base64.URL_SAFE);
How can I fix that? Is that backend related or browser or even Android client?

I think something is encoding your \n to
on the server side, and Safari is removing it again, rather than other browsers adding it in.
This HTML works fine in chrome for me (save it in a file called a.html on your desktop and open it):
<html><body><img src="data:image/png;base64, iVBORw0KGgoAAAAN
SUhEUgAAAAUA
AAAFCAYAAACNbyblAA
AAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg=="></img></body></html>
I think you might need to put more code in your question showing how you retrieve the data, base64 it, incorporate it into the page being sent to browser etc
Also, take a look at the raw responses from your server, in the browser developer tools or a web debugging proxy like Fiddler, to see exactly what your server is sending - using Inspect Element might be showing you the data after it's parsed/interpreted/rendered rather than raw

Related

how to play video from server?

i want to have a URL like this one (https://www.ooklnet.com/files/381/381489/video.mp4) where when you click it and itll play the video. Thing is this isnt my website or video. i tried my URL which i thought was corrct (http://54.XXX.XXX.238/srv/ProductVideos/lazar108#hotmail.com/s/s_7s.MP4) and it gives me this error:
The requested URL /srv/ProductVideos/lazar108#hotmail.com/s/s_7s.MP4 was not found on this server.
I know for a fact that theres a video in the file path on my server. Proof:
(I need this URL for my android app so i can display the video in the app.)
How can i create a link like this one (https://www.ooklnet.com/files/381/381489/video.mp4)?
I have a Ubuntu 14.04.4 server with AWS EC2!
Any help would be appreciated!!
Thank you!
1) your EC2 has to have security groups open to allow any access to port 80 from the Internet
2) your EC2 has to be running some web server software such as apache
3) apache needs to be configured to serve files, check the document root
4) apache needs to be configured to correctly send mp4 with the right mime type headers see this answer Apache not serving .mp4 files correctly - shows the contents of the file rather than a download prompt
If it is apache ( and not nginx or another web server) you are using check the access log file /var/log/apache2/access.log and the default error log /var/log/apache2/error.log

oAuth support in a WebView

So I've created a simple WebView application that wraps an already existing mobile friendly site and displays it on the device. I've enabled javascript, supported screen orientation changes, etc...
I've run into an issue with the oAuth support though. Accessing the site from the chrome browser on the device, everything runs fine.
If I try to access the site from the app/WebView, it will push me over to the oAuth screen, let me input credentials and everything, but the moment it tries to push me back to the website and log me in, I get this:
Failed to recognize URL query:
https://exittix.com/frontend/login/redirect.html#access_token=******************************&expires_in=********&state=****client_id=******************network*****facebook*****display***popup****callback****_hellojs_agj27sx5****state****oauth_proxy***https***auth-server.herokuapp.com%2Fproxy***scope***basic_profile***email***basic***oauth***version***auth***https***facebook.com%2Foauth***
The * is used to protect data.
So, any ideas why oAuth isn't working inside a JS enabled webview but works fine in the mobile chrome browser for android?
Thanks in advance for your help!
EDIT:
Ok, so I've tracked the error I'm getting back to redirect.html.
This page calls some javascript. If the javascript fails to redirect, then it displays that error I have above instead.
The javascript being called to handle the oAuth is Andrew Dodson's hello.js script.
You can see it HERE.
I've concluded that the second half of the error's url is indeed the unhandled JSON.
Here's what the returned data looks like after I've decoded it from the URL encoded characters:
{"client_id":"************.apps.googleusercontent.com","network":"google","display":"popup","callback":"_hellojs_********","state":"","oauth_proxy":"https://auth-server.herokuapp.com/proxy","scope":["https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/userinfo.email","basic"],"oauth":{"version":2,"auth":"https://accounts.google.com/o/oauth2/auth"}}&access_token=***.*.*****_*********************************************************&token_type=Bearer&expires_in=3600
Any ideas why this isn't getting handled properly in the WebView?

Phonegap / Cordova include external src without http / https

So here it is, I'm starting a Phonegap app and would like to use a given library. In the library code it tries to reach some URL with this form :
//img.site.com/given_img.png
without http or https at the beginning so it will adapt nicely. But when launching the app on my phone I see it tries to reach :
file://img.site.com/given_img.png
Not http or https... But file protocol. Obviously it fails to load...
Anyone knows how to deal with this ?
Thanks ahead !
As far as I can tell, after researching this for some time... Currently there is no solution out of the box. You have to check the code with JS and force add the wanted protocol into it before execution. I simply changed the way I wanted to do things and avoided that kind of situation.
The idea behind having src="//domain.com/some/pic" is so that the browser will request those assets with the protocol matching your website, meaning, if your website is running on http - it will request the picture over http, vs if your website is running on https it will request the image with https://.
#Jeremy is right, there's no option at the moment.
But you can take the protocol matching your website with var protocol = window.location.protocol and use that in your src={{ protocol + image }}
This is to prevent from writing hard-coded http / https and mix secure with non-secure content in your website which causes errors to jump like "This Page Contains Both Secure and Non-Secure Items"

Email dialog HTML ignores some tags Titanium Moblie

I'm currently building an app that has Email sending capabilities. I'm trying to send an Email with the relevant information and includes a link to the original post that is being sent. the original post is created as an HTML code segment, so I have to send the Email as an HTML. i create the Email dialog like this:
var mail = Ti.UI.createEmailDialog({
subject:'FW:'+post.desc,
html:true,
messageBody: '<br><br>view original post<br><br><b style="font-size:1.5em;font-family:Arial">'+post.desc+'</b><br><br><i>'+metaData.text.toString().replace(/\n/g,'<br>')+' </i><br><br>'+post.htmlData
});
Ti.API.debug(mail.messageBody)
mail.open();
when I ran the app on my device, I got the option of sending via "mail" or via "Gmail". when sent via "mail", all the link tabs and and were ignored and striped so the Email didn't include them. however, the "Gmail" option left everything as suppose to.
any thoughts?
the question was asked also in Titanium Q&A
Apparently, the default Email client for Android doesn't have a HTML renderer and disregards it, and the Gmail Android client won't parse certain tags like .
it seems to me like the answer will be using temporary files and attachments.
if anybody comes up with a better answer I'll be very happy.
happy X-mas | Hanukah | festivus for the rest of us

Android webview.loadUrl works with one URL GET string but not Another

I am new at Java and Android so thank for you help.
I wrote a simple Android WebView app to view my home webcam. I can get webview to return a snapshot of the webcam but not send controls to pan etc.
The line that works is
webview.loadUrl("http://myhost.com/snapshot.cgi?user=myusername&pwd=mypassword");
This works and returns a snapshot of my current webcam a FOSCAM
This line DOES NOT WORK!
webview.loadUrl("http://myhost.com/decoder_control.cgi?command=28?user=myusername&pwd=mypassword");
The above line uses that same username / password but returns a HTTP 401 Unauthorized error
WHAT is going on.. they both work fine in a browser? and in CURL
It's likely the second question mark... Why is that there? I imagine it should be an ampersand unless you have some weird protocol.

Categories

Resources