Skip to content

Instantly share code, notes, and snippets.

const router = async (req, res) => {
if (req.method === 'POST') {
return postS3(req, res)
} else if (req.method === 'GET') {
return getS3(req, res)
} else {
throw createError(405, 'Invalid method')
}
}
const generateUUID = (size = 10) => {
return randomBytes(Math.ceil(size * 3 / 4))
.toString('base64')
.slice(0, size)
.replace(/\+/g, 'a')
.replace(/\//g, 'b')
}
const postS3 = async (req, res) => {
const {contentType} = await json(req) // we are requiring the ContenType from the request
@paulogdm
paulogdm / s3-get.js
Last active July 29, 2018 02:59
[micro-s3-example] Get Signed URL
const getS3 = async (req, res) => {
const s3key = `${req.url.substr(1)}` // we need to remove the first backslash from the url
const params = {
Bucket: config.bucket_name,
Key: s3key,
Expires: 60 * 60 * 24 // 1 day
}
try {
04d5e324d86e49a5d055f7e9e0b89378688fb4851ec52853b9c1d1c6b763b55515feeb09f1efd11c58c97fc3483207a591a0dc5d9e31e5866c929425a7cbbfe16e
@paulogdm
paulogdm / gist:e15c84534f713e0d66e76ceb296f2268
Created September 26, 2017 15:58 — forked from nilo/gist:c2a31a0f9f29c88145ca
Using cedilha - ArchLinux Cinnamon
Author: Nilo Dantas - n1lo
Based on: https://bugs.launchpad.net/ubuntu/+source/ibus/+bug/518056 - helio-valente post
How to use Cedilha on US Keyboard on ArchLinux
1) Put: English(US, internacional with dead Keys) on your system keyboard layout.
2) Editing the files:
sudo vim /usr/lib/gtk-3.0/3.0.0/immodules.cache