Gmail's broken image links when sending mails through Django - image

I'm sending an email using the SMTP protocol in Django. When I send the image link it is like this:
https://example.com/images/pic1.jpg
But Gmail converts it to something like this:
https://ci5.googleusercontent.com/proxy/vI79kajdUGm6Wk-fjyicDLjZbCB1w9NfkoZ-zQFOB2OpJ1ILmSvfvHmE56r72us5mIuIXCFiO3V8rgkZOjfhghTH0R07BbcQy5g=s0-d-e1-ft#https://example.com/images/pic1.jpg
I tried the image URL proxy whitelist setting. It is showing the preview of the image.But image links are not working.
PS: I have also tried methods suggested here to no avail.
Update 1:
The images are stored in the AWS s3 bucket. If I make them public then they work fine. But I can't make them public.Is there any other way?

The images are stored in the AWS s3 bucket. If I make them public then they work fine. But I can't make them public.Is there any other way?
The short answer is "no" if you want to keep referencing image through URLs as GMail's image proxy needs access to your images over the "public" internet one way or another.
This question is a bit off topic as it has little to do with Django but if you're using GMail for business you can configure which URLs should not go through the proxy. This should allow you to prevent images served from your "private" S3 bucket URL from being proxied. Note that this will only work for GMail accounts within your business domain; the images will be proxied and fail to load if the email is sent to a non-business or a different business Gmail account for example.
One another way you could avoid proxying completely it to attach the image in the email instead of referring to it through an URL. You can refer to this answer for how to achieve that https://stackoverflow.com/a/3787766/70191.

Related

Upload image to imgur without exposing client_id, but directly from browser

OK, I want to start using imgur for my new web app (on all browsers and my server) and will submit anonymous images for paid storage, but from the user's browser to minimize loading on my server. Almost all the software runs in javascript client-side (with very few server interactions... hence fast and distributed).
Currently the only way I can see using the ID from imgur is to first bring the image to my server and then send to imgur with my ID. Because putting it into the javascript on the browser makes the ID visible to the world.
I was hoping for some kind of solution like: I call imgur to get a token good for ONE time use only. The user gets the token from my server (which I would have previously polled imgur to get) and then I send to my javascript code on their browser, which would upload the image directly to imgur with the token. The token is then dead, and it doesn't matter if someone else sees it, it cannot be used again.
Does imgur API have anything like this? Or maybe another solution? Key points are:
Don't upload to my server since I wont keep it there anyway
Don't expose my client ID to world on user's browser in Javascript
Any help would be appreciated.

In Brightcove, can I retrieve a video's thumbnail WITHOUT a media API token?

I would like to use Javascript to retrieve thumbnail URLs from Brightcove-hosted videos.
I can't see a way to do that without exposing my Media API token to the client browser. (The with-token method is documented here.)
I don't need a token to show the whole video, so it seems insane and unnecessary that I need a token to get the thumbnail url, which obviously I would want to show to the user anyway.
The only workaround I can devise is to create a middleman interface on the server. (The client JS makes a request to my server, which uses the token to request the thumbnail from BC, then returns it back to the JS.) That's just annoying.
Am I missing something? Is there an alternate way to retrieve video thumbnails in the client without exposing the Media API key?
According to Brightcove's support, they tell me that the answer is "NO".
They do recommend a server-side relay, which is what I ended up writing, and it works fine.
Disappointing, though.

Examples of Datastore read/write from ajax?

My single page app is hosted on Google's cloudstore. I love that I don't have to worry about a server. The app is, naturally, javascript heavy.
Now I would like to add a feature where users can store some data, generate a link to be shared with others and retrieve stored data. Think of a pastebin where some snippet of text is saved and a unique link is generated to be shared with others.
In fact, if it helps, think of this as my attempt to create a pastebin without having to setup a server.
It looks like Google's cloud datastore nosql solution is what I want. Given a key, it will return a snippet of text. However, all the examples on the documentation page imply that I have to setup a back end service using python, node, etc.
Questions:
Can't I just read and write from a web page, perhaps using ajax style http call (since I need to get and put text snippets once data has already been loaded)? I believe I can take care of cross-origin issues by changing some configs in the cloudstore static website server.
Obviously I don't want to serve any encryption keys from the web page. I'm hoping that since my site is served from Google as well, I can configure the nosql service handle permissions intelligently for this scenario.
Is there any documentation which shows how to do this correctly?
Google Datastore is not supposed to be used from client side, it's a served side database. You cannot do that w/o having server side code to authenticate, authorize and validate db related requests.
But there're an alternative. Firebase is a ready to use backend for client side applications, including Javascript apps. It's a separate project, that belongs to Google but not (yet?) part of Google Cloud. Take a look - https://www.firebase.com/
Although the API Rest is still beta, it is possible now to connect from a web client or anything RESTful capabilities. https://cloud.google.com/datastore/reference/rest/

Is there a general image service "unshort" api service?

I am currently updating my Twitter client Nymphicus to use http://unshort.me/ to unshorten all the links in tweets. Before that I implemented all the url shortener APIs myself but there are so many...
With images it is quite the same: I do implement all the different APIs out there to get thumbnails but I wonder if anyone knows a service similar to unshort.me which gives you back the url of a thumbnail if you send the image link?
http://embed.ly/ does it, 10k requests free. otherwise it's a pay service.

Recommended way to send details to the client for a web analytics service

When creating a service like Google Analytics or StatCounter, I want to do it a little bit different in the data storage part:
A user visits my client's website.
JS code or 1 pixel image is downloaded from my server.
Request sent to my server, where the data is processed.
Things like country, returning customer, bounce rate, etc are calculated.
Instead of storing this data in my server, I want to store it in the client's server.
The client is an individual or business who is using my "service" for web analytics of their website.
Assuming that they are prepared to create a db schema that I choose, what is the recommended way to send the data to them to store?
The only thing I can think of is, asking them to give me a URL in their server, to which I will POST a JSON string, which they can store or do whatever they want.
Apart from HTTP POST, are their any other choices I have to send the data to them?
You could store the data on your own server then provide a mechanism for the client to download it. This would save you the burden of entering and testing a different URL for each customer.
It would also mean that you would only need one SSL URL and authentication method for security. Otherwise you would need to make sure each customer has a working SSL and get your script to log onto each of them when it deposits the data.

Resources