SlideShare a Scribd company logo
Storing User
Files with
Express,
Stormpath, and
Amazon S3
@rdegges
I’m Randall Degges
Developer Evangelist at
Stormpath
Python / Node / Go
Hacker
Agenda
- Stormpath Intro (5 minutes)
- Main Talk (30 minutes)
- Q/A (15 minutes)
Intro to Stormpath
API Service Website Mobile App
We Do a Lot
- Libraries for many languages
- AD / LDAP
- Single Sign On (SAML)
- OAuth2
- Social Login
- Multi-Tenancy
- Groups and Roles
- Email Workflows
What’s the problem?
www.awesome.io
avatar.png
receipt.pdf
invoice.pdf
Stormpath!
???
How do people
usually store user
files?
Database Columns
CREATE TABLE IF NOT EXISTS users (
id UUID DEFAULT uuid_generate_v4(),
email TEXT PRIMARY KEY,
password TEXT NOT NULL,
avatar TEXT
);
avatar.png
Base64 encode
No!!!
- Makes DB queries for each image view.
- Slows down DB.
- DBs aren’t good at this sort of IO (heavy disk
reading).
- Slow performance for end users.
Your Webserver(s)
Webserver
avatar.png
avatar.png
avatar.png avatar.png avatar.png
avatar.png
avatar.pngavatar.png
Storing User Files with Express, Stormpath, and Amazon S3
Amazon S3
- Reliability.
- Durability.
- Availability.
- Cost.
- Speed.
- Security ACLs.
How S3 Works
avatar.png
webserver
S3 Bucket
Custom Data
(for user)
User CustomData
{
"href": "https://api.stormpath.com/v1/accounts/gbMUL3uP8rFLZUMAw2XhI",
"email": "r@rdegges.com",
"givenName": "Randall",
"surname": "Degges",
"customData": {
"href": "https://api.stormpath.com/v1/accounts/gbMUL3uP8rFLZUMAw2XhI/customData",
"s3": {
"fluent.jpg": {
"href": "https://s3.amazonaws.com/express-stormpath-
s3/gbMUL3uP8rFLZUMAw2XhI/fluent.jpg",
"lastModified": "2016-10-05T23:20:53.508Z"
},
"wallhaven-204175.jpg": {
"href": "https://s3.amazonaws.com/express-stormpath-s3/gbMUL3uP8rFLZUMAw2XhI/wallhaven-
204175.jpg",
"lastModified": "2016-10-06T01:08:58.898Z"
}
}
}
}
Cool, Right?
So… Let’s Build Something!
$ npm install express
$ npm install express-stormpath
$ npm install express-stormpath-s3
"use strict";
const express = require("express");
const stormpath = require("express-stormpath");
const stormpathS3 = require("express-stormpath-s3");
let app = express();
app.use(stormpath.init(app));
app.use(stormpath.getUser);
// Other middleware here
// Routes here
app.listen(3000);
The Magic!
/register
/login
Storing User Files with Express, Stormpath, and Amazon S3
Storing User Files with Express, Stormpath, and Amazon S3
app.use(stormpathS3({
awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
awsBucket: 'express-stormpath-s3'
}));
This sets up the S3 client and adds simple
file methods onto req.user. Required.
Setup Done!
Upload Files
req.user.uploadFile("./avatar.png", (err) => {
if (err) throw err;
console.log("Successfully uploaded file!");
});
Path to local file you want to upload.
Upload Files (cont)
req.user.uploadFile("./avatar.png", "public-read", (err) => {
if (err) throw err;
console.log("Successfully uploaded file!");
});
Desired ACL for file.
Delete Files
req.user.deleteFile("avatar.png", (err) => {
if (err) throw err;
console.log("Successfully deleted file!");
});
(demo)
Resources
- https://github.com/rdegges/express-
stormpath-s3
- https://aws.amazon.com/s3/
- https://stormpath.com/
- https://github.com/rdegges/express-
stormpath-s3-webinar
- https://docs.aws.amazon.com/AmazonS3/lat
est/dev/acl-overview.html
You’re
awesome.
@rdegges

More Related Content

Viewers also liked (20)

PPTX
Token Authentication in ASP.NET Core
Stormpath
 
PPTX
Custom Data Search with Stormpath
Stormpath
 
PPTX
Spring Boot Authentication...and More!
Stormpath
 
PPTX
Stormpath 101: Spring Boot + Spring Security
Stormpath
 
PDF
JWTs in Java for CSRF and Microservices
Stormpath
 
PPTX
Instant Security & Scalable User Management with Spring Boot
Stormpath
 
PPTX
Multi-Tenancy with Spring Boot
Stormpath
 
PDF
The Ultimate Guide to Mobile API Security
Stormpath
 
PPTX
Beautiful REST+JSON APIs with Ion
Stormpath
 
PPTX
Browser Security 101
Stormpath
 
PPTX
REST API Security: OAuth 2.0, JWTs, and More!
Stormpath
 
PPTX
Secure API Services in Node with Basic Auth and OAuth2
Stormpath
 
PPTX
Building Secure User Interfaces With JWTs (JSON Web Tokens)
Stormpath
 
PDF
Getting Started With Angular
Stormpath
 
PDF
Securing Web Applications with Token Authentication
Stormpath
 
PDF
Build a REST API for your Mobile Apps using Node.js
Stormpath
 
PPTX
Token Authentication for Java Applications
Stormpath
 
PDF
Building Beautiful REST APIs with ASP.NET Core
Stormpath
 
PPTX
Build a Node.js Client for Your REST+JSON API
Stormpath
 
PPTX
So long scrum, hello kanban
Stormpath
 
Token Authentication in ASP.NET Core
Stormpath
 
Custom Data Search with Stormpath
Stormpath
 
Spring Boot Authentication...and More!
Stormpath
 
Stormpath 101: Spring Boot + Spring Security
Stormpath
 
JWTs in Java for CSRF and Microservices
Stormpath
 
Instant Security & Scalable User Management with Spring Boot
Stormpath
 
Multi-Tenancy with Spring Boot
Stormpath
 
The Ultimate Guide to Mobile API Security
Stormpath
 
Beautiful REST+JSON APIs with Ion
Stormpath
 
Browser Security 101
Stormpath
 
REST API Security: OAuth 2.0, JWTs, and More!
Stormpath
 
Secure API Services in Node with Basic Auth and OAuth2
Stormpath
 
Building Secure User Interfaces With JWTs (JSON Web Tokens)
Stormpath
 
Getting Started With Angular
Stormpath
 
Securing Web Applications with Token Authentication
Stormpath
 
Build a REST API for your Mobile Apps using Node.js
Stormpath
 
Token Authentication for Java Applications
Stormpath
 
Building Beautiful REST APIs with ASP.NET Core
Stormpath
 
Build a Node.js Client for Your REST+JSON API
Stormpath
 
So long scrum, hello kanban
Stormpath
 

More from Stormpath (7)

PPTX
How to Use Stormpath in angular js
Stormpath
 
PPTX
Rest API Security
Stormpath
 
PPTX
Elegant Rest Design Webinar
Stormpath
 
PPTX
Secure Your REST API (The Right Way)
Stormpath
 
PPTX
Build A Killer Client For Your REST+JSON API
Stormpath
 
PPTX
REST API Design for JAX-RS And Jersey
Stormpath
 
PPTX
Design Beautiful REST + JSON APIs
Stormpath
 
How to Use Stormpath in angular js
Stormpath
 
Rest API Security
Stormpath
 
Elegant Rest Design Webinar
Stormpath
 
Secure Your REST API (The Right Way)
Stormpath
 
Build A Killer Client For Your REST+JSON API
Stormpath
 
REST API Design for JAX-RS And Jersey
Stormpath
 
Design Beautiful REST + JSON APIs
Stormpath
 
Ad

Recently uploaded (20)

PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Ad

Storing User Files with Express, Stormpath, and Amazon S3