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
export async function main(event, context, callback) { | |
parser(event).then(() => { | |
uploadFile(event.body.file) | |
.then(() => { | |
// Handle successful upload | |
}) | |
.catch(() => { | |
// Handle upload errors | |
}); | |
}); |
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 uploadFile = (buffer) => new Promise((resolve, reject) => { | |
const bucketName = "YOUR-BUCKET-NAME"; | |
const fileName = "YOUR-FILE-NAME.EXTENSION"; | |
const data = { | |
Bucket: bucketName, | |
Key: fileName, | |
Body: buffer, | |
}; | |
s3.putObject(data, (error) => { | |
if (!error) { |
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 getContentType = (event) => { | |
const contentType = event.headers['content-type'] | |
if (!contentType) { | |
return event.headers['Content-Type']; | |
} | |
return contentType; | |
}; | |
const parser = (event) => new Promise((resolve, reject) => { | |
const busboy = new Busboy({ |
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
handleFileUpload = (event) => { | |
this.setState({ file: event.target.files }); | |
}; | |
submitFile = (event) => { | |
event.preventDefault(); | |
const formData = new FormData(); | |
formData.append('file', this.state.file[0]); | |
axios | |
.post( |
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
<form onSubmit={this.submitFile}> | |
<input | |
label="Upload file" | |
type="file" | |
onChange={this.handleFileUpload} | |
/> | |
<button type="submit">Upload</button> | |
</form> |
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
{ | |
"Version": "2012-10-17", | |
"Id": "Policy1532447175542", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": "*", | |
"Action": "s3:putObject", | |
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*" | |
} |
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
"scripts": { | |
"build:translations": "react-intl-cra './src/**/*.js' -o ./build/messages/messages.json && babel scripts/translate.js | node && babel scripts/copyTranslationsToDB.js | node", | |
"fetch:translations": "babel scripts/fetchTranslationsFromDB.js | node", | |
} |
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
import axios from 'axios'; | |
import * as fs from 'fs'; | |
import { sync as mkdirpSync } from 'mkdirp'; | |
const supportedLanguages = ['en', 'hu']; | |
const API_URL = "YOUR API URL"; | |
const LANG_DIR = './src/translations/'; | |
axios.get(API_URL).then(() => { |
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
"scripts": { | |
"build:translations": "react-intl-cra './src/**/*.js' -o ./build/messages/messages.json && babel scripts/translate.js | node && babel scripts/copyTranslationsToDB.js | node", | |
}, |
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
import axios from 'axios'; | |
import messagesEn from './src/translations/temp/en.json'; // Import the extracted tokens | |
const messageKeys = []; | |
const API_URL = "YOUR API URL HERE"; | |
Object.keys(messagesEn).forEach((message) => { | |
messageKeys.push(message); // I only send the tokens, not the default messages | |
}); |
NewerOlder