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

Automation Frees Up PetRescue’s Staff to Help Pets Find Their Forever Homes

As we spend more time at home, many of us are adopting pets for the joy, companionship and a surprising range of health benefits. In Australia, where our nonprofit customer PetRescue is located, there’s a shortage of pets to adopt. Last August, the Guardian reported that dog shelters in Australia emptied and adoption fees for puppies were running as high as $AUS1800.

Read more
Cloudinary and Contentful Make Modern Content Management Easier

I am pleased to share that Cloudinary and Contentful have joined forces to further streamline the creation, processing, and delivery of online content through Cloudinary’s digital asset management (DAM) solution and advanced transformation and delivery capabilities for images and video. What’s more, the partnership delivers a headless approach to DAM. By leveraging APIs for media management tasks, marketers and developers alike benefit from an integrated stack of optimized assets for optimization and automation. As a result, page loads are fast and beautiful, and at scale—with less overhead and effort.

Read more
Introducing Cloudinary's Nuxt Module

Since its initial release in October 2016 by the Chopin brothers as a server-side framework that runs on top of Vue.js, Nuxt (aka Nuxt.js) has gained prominence in both intuitiveness and performance. The framework offers numerous built-in features based on a modular architecture, bringing ease and simplicity to web development. Not surprisingly, Nuxt.js has seen remarkable growth in adoption by the developer community along with accolades galore. At this writing, Nuxt has earned over 30K stars on GitHub and 96 active modules with over a million downloads per month. And the upward trend is ongoing.

Read more
How Quality and Quantity can go Hand in Hand

When it comes to quality versus quantity, you’ll often hear people say, “It’s the quality that counts, not the quantity”. While that’s true in many situations, there are also cases where you want both quality and quantity. You may have thousands of images on your website and you want them all to look great. This is especially important if your website allows users to upload their own content, for example, to sell their own products or services. You don't want their poor quality images to reflect badly on your brand.

Read more
Product Videos 101: What Makes Them Great?

A product’s benefits and usage, including its value proposition, features, and instructive details, are best demonstrated through video. Product-video types vary, depending on the funnel, channel, and audience, the most popular ones being demos, reviews, installation, and how-tos.

Read more