Skip to content

Commit

Permalink
FIX export + hide bucket name from url + ensure no special chars in u…
Browse files Browse the repository at this point in the history
…pload
  • Loading branch information
slecorne committed Dec 5, 2022
1 parent 8a232ed commit e1a6972
Show file tree
Hide file tree
Showing 6 changed files with 10,348 additions and 9,903 deletions.
211 changes: 199 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"react-router-dom": "^6.4.0",
"react-scripts": "5.0.1",
"redux": "^4.2.0",
"short-uuid": "^4.2.2",
"typescript": "^4.7.4",
"web-vitals": "^2.1.4"
},
Expand Down
12 changes: 6 additions & 6 deletions src/components/project/UploadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "@chakra-ui/react";
import * as React from "react";
import { useDispatch } from "react-redux";
import shortId from 'short-uuid';

import { useNavigate } from "react-router-dom";
import { setIsNew } from "../../features/zones/zonesSlice";
Expand Down Expand Up @@ -59,15 +60,14 @@ export default function UploadButton() {
variant="solid"
colorScheme={"brand"}
onClick={() => {
ReactS3Client.uploadFile(file)
// create file name with key and extension + ensure no special characters
const fileNameParts = fileName.split('.');
ReactS3Client.uploadFile(file,
`${shortId.generate()}_${fileNameParts[0].replace(/[^a-zA-Z0-9 ]/g, '')}.${fileNameParts.pop()}`)
.then((data: any) => {
onClose();
navigate(
`/figma?bytesimBucket=${
process.env.REACT_APP_S3_BUCKET
}&region=${
process.env.REACT_APP_S3_REGION
}&key=${encodeURIComponent(data.key)}&new=true`
`/figma?key=${encodeURIComponent(data.key)}&new=true`
);
setFile(undefined);
setFileName("");
Expand Down
Loading

0 comments on commit e1a6972

Please sign in to comment.