Cloudinary Blog

Securely Uploading Images to Cloudinary by Email With Heroku and Sendgrid

Securely Uploading Images to Cloudinary by Email

Despite United States founder Benjamin Franklin’s wisdom that three can keep a secret if two of them are dead, you as developers often need contributions from third parties for your project. However, in today’s digital world, security in software development is a predominant concern. With respect to management of rich media, it’d be ideal if those folks could upload images or videos to your Cloudinary account without having to log in.

This post explains how to enable third parties, including project contributors and end-users, to do that by email with free, integrated tools, including SendGrid, Cloudinary’s email server. Actually, that basic function already exists in many electronic devices, from smartphones to smart fridges. Setting it up is a snap.

The Process Flow

First, you need an email server but with a twist. As mentioned, we at Cloudinary leverage the one from SendGrid, which accepts any email it receives and then parses it.

Here’s the process flow:

  1. A third party sends an email with an image attachment to the address you configured with your email provider.
  2. For each email, SendGrid creates a webhook and sends it to a Cloudinary app that’s deployed on Heroku.
  3. The app parses the webhook and uploads the image to Cloudinary as an unsigned upload.

The Prerequisites

Following are the requirements, starting with the final destination, Cloudinary:

Note: Some of the steps generate parameters for the next step. We’ll work on eliminating that complexity.

  • A Cloudinary account. A free one will do just fine. Log in to the dashboard and copy your Cloudinary URL from there for the next step.
  • A platform on which to host your code. Even though you will execute Python code on Heroku, any platform will do. The code repository is on GitHub. You deploy the code with just a button click with no manual efforts whatsoever.
  • An email-service provider. Cloudinary has picked Twilio’s SendGrid as the service provider for receiving and sending emails for uploads to Cloudinary’s Media Library, as described in this post. A free account will do just fine
  • A registered domain. You’ll need to create mail exchange (MX) records to point to the email-service provider.

The Procedure

Refer to the readme on GitHub, which explains how the Cloudinary app cloudinary-email-uploader works with SendGrid's incoming parser to empower third parties to send email along with images to your Cloudinary account. In addition, you’ll learn how to—

  • Acquire the prerequisite free software.

  • Configure and deploy cloudinary-email-uploader.

The complete code is also on GitHub.

Do give it a try and comment your results below.

Recent Blog Posts

Why the Future of E-commerce Is Live

In a previous post, I discussed how “going live” is gaining popularity across industries and verticals. What began as a way for gamers to jam together has evolved into a medium for broader entertainment and business purposes. To continue the conversation, this post unpacks the current trends of shoppable live streams to shine a light on how brands are leveraging “lives” to connect with shoppers in new ways.

Read more
An Overview of Live-Streaming Video Trends

“Let’s go live.” For decades, that’s what newscasters say as they cut to real-time footage of a colleague reporting in the field. The live-video feed adds visual interest and perspective to a story beyond what can be communicated by someone sitting behind the news desk. In the same way, live-streaming video nowadays adds context to other consumer environments. From gaming and events to shopping and social media, “going live” enhances everyday experiences, and it’s something anyone can do with relative ease.

Read more
Readying Live Streams for Video on Demand

When planning a live broadcast or stream, companies often overlook the redistribution phase, but live-stream videos are useful well beyond their initial streaming. Why? Because not everyone watches the first run. For a wider audience, it makes sense to repost live content on your website under an “events” tab, on YouTube, and other social sites for video on demand (VOD). However, preparing footage for reposting can be a lot of work.

Read more
Optimize Visual Media for a Fast and Captivating Digital Experience

Did you know that humans process imagery 60,000 times faster than text? In fact, 90% of the information our brains process is visual, which makes it seem a no-brainer—pun intended—that brands are connecting with consumers through visual content online. However, adding media assets like images and videos to websites comes with a tradeoff: the more media, the heavier the site, which results in a noticeable slowdown in page loads and a reduction in content quality.

Read more