Skip to content

Instantly share code, notes, and snippets.

@llucasshenrique
Created August 17, 2019 07:05
Show Gist options
  • Save llucasshenrique/88ceb2b632bd17ad2a663588e7277fbe to your computer and use it in GitHub Desktop.
Save llucasshenrique/88ceb2b632bd17ad2a663588e7277fbe to your computer and use it in GitHub Desktop.
Gabigode
const images = [
{
file: '00.txt',
source: '00'
},
{
file: '01.txt',
source: '01'
},
{
file: '02.txt',
source: '02'
}
]
module.exports = images
const fs = require('fs')
const path = require('path')
const images = require('./images')
const main = (fileList) => {
const randomFromArray = (fileList) => {
return fileList[Math.floor(Math.random() * fileList.length)]
}
const loadFile = (selected) => {
const filePath = path.join(__dirname, 'files', selected.file)
return fs.readFileSync(filePath, { encoding: 'base64' })
}
const uploadFile = (selected) => {
//logica para fazer o upload
}
const selected = randomFromArray(images)
const file = loadFile(selected)
const upload = uploadFile(file)
}
main(images)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment