Skip to content

Commit

Permalink
fixed issue where fileupload would grab file extension and put it in …
Browse files Browse the repository at this point in the history
…the name
  • Loading branch information
StevenCreates committed Oct 1, 2020
1 parent 2c6ef96 commit 448a1e6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/components/Upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import S3 from "react-aws-s3";

function Upload() {
const fileInput = useRef();
const handleClick = event => {
const handleClick = (event) => {
event.preventDefault();
let file = fileInput.current.files[0];
let newFileName = fileInput.current.files[0].name;
let newFileName = fileInput.current.files[0].name.replace(/\..+$/, "");
const config = {
bucketName: "bucket",
dirName: "yourdirectory" /* optional */,
region: "us-west-2",
accessKeyId: "key",
secretAccessKey: "secret"
bucketName: process.env.REACT_APP_BUCKET_NAME,
dirName: process.env.REACT_APP_DIR_NAME /* optional */,
region: process.env.REACT_APP_REGION,
accessKeyId: process.env.REACT_APP_ACCESS_ID,
secretAccessKey: process.env.REACT_APP_ACCESS_KEY,
};
const ReactS3Client = new S3(config);
ReactS3Client.uploadFile(file, newFileName).then(data => {
ReactS3Client.uploadFile(file, newFileName).then((data) => {
console.log(data);
if (data.status === 204) {
console.log("success");
Expand Down

0 comments on commit 448a1e6

Please sign in to comment.