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

Our $2B Valuation

By
Blackstone Growth Invests in Cloudinary

When we started our journey in 2012, we were looking to improve our lives as developers by making it easier for us to handle the arduous tasks of handling images and videos in our code. That initial line of developer code has evolved into a full suite of media experience solutions driven by a mission that gradually revealed itself over the course of the past 10 years: help companies unleash the full potential of their media to create the most engaging visual experiences.

Read more
Direct-to-Consumer E-Commerce Requires Compelling Visual Experiences

When brands like you adopt a direct–to-consumer (DTC) e-commerce approach with no involvement of retailers or marketplaces, you gain direct and timely insight into evolving shopping behaviors. Accordingly, you can accommodate shoppers’ preferences by continually adjusting your product offering and interspersing the shopping journey with moments of excitement and intrigue. Opportunities abound for you to cultivate engaging customer relationships.

Read more
Automatically Translating Videos for an International Audience

No matter your business focus—public service, B2B integration, recruitment—multimedia, in particular video, is remarkably effective in communicating with the audience. Before, making video accessible to diverse viewers involved tasks galore, such as eliciting the service of production studios to manually dub, transcribe, and add subtitles. Those operations were costly and slow, especially for globally destined content.

Read more
Cloudinary Helps Minted Manage Its Image-Generation Pipeline at Scale

Shoppers return time and again to Minted’s global online community of independent artists and designers because they know they can count on unique, statement-making products of the highest quality there. Concurrently, the visual imagery on Minted.com must do justice to the designs into which the creators have poured their hearts and souls. For Minted’s VP of Engineering David Lien, “Because we are a premium brand, we need to ensure that every single one of our product images matches the selected configuration exactly. For example, if you pick an 18x24 art print on blue canvas, we will show that exact combination on the hero images in the PDF.”

Read more
Highlights on ImageCon 2021 and a Preview of ImageCon 2022

New year, same trend! Visual media will continue to play a monumental role in driving online conversions. To keep up with visual-experience trends and best practices, Cloudinary holds an annual conference called ImageCon, a one-of-a-kind event that helps attendees create the most engaging visual experiences possible.

Read more