Created
August 17, 2019 07:05
-
-
Save llucasshenrique/88ceb2b632bd17ad2a663588e7277fbe to your computer and use it in GitHub Desktop.
Gabigode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const images = [ | |
{ | |
file: '00.txt', | |
source: '00' | |
}, | |
{ | |
file: '01.txt', | |
source: '01' | |
}, | |
{ | |
file: '02.txt', | |
source: '02' | |
} | |
] | |
module.exports = images |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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