Skip to content

Commit

Permalink
chore: treat file as binary, proper disable upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rafasdc committed Sep 25, 2024
1 parent cc6c676 commit 64d6ae6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
4 changes: 1 addition & 3 deletions app/backend/lib/s3upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ s3upload.post('/api/s3/upload', limiter, async (req, res) => {
return res.status(404).end();
}
const form = formidable(commonFormidableConfig);

const files = await parseForm(form, req).catch((err) => {
return res.status(400).json({ error: err }).end();
});
Expand All @@ -42,7 +41,7 @@ s3upload.post('/api/s3/upload', limiter, async (req, res) => {
if (!uploaded) {
return res.status(200).end();
}
const file = fs.readFileSync(uploaded.filepath, 'utf8');
const file = fs.readFileSync(uploaded.filepath);

const params = {
Bucket: AWS_S3_BUCKET,
Expand All @@ -51,7 +50,6 @@ s3upload.post('/api/s3/upload', limiter, async (req, res) => {
};

const uploadResult = await uploadFileToS3(params);

if (uploadResult) {
return res.json({ status: 'success' });
}
Expand Down
3 changes: 1 addition & 2 deletions app/pages/analyst/gis/coverages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const CoveragesTab = () => {
const [selectedFile, setSelectedFile] = useState<File>();
const [isUploading, setIsUploading] = useState(false);
const [uploadSuccess, setUploadSuccess] = useState(false);

const fileComponentValue = [
{
id: '',
Expand Down Expand Up @@ -183,7 +182,7 @@ const CoveragesTab = () => {
<ButtonLink
onClick={handleUpload}
href="#"
disabled={isUploading || selectedFile === null}
disabled={isUploading || !selectedFile}
>
{isUploading ? 'Uploading' : 'Upload'}
</ButtonLink>
Expand Down

0 comments on commit 64d6ae6

Please sign in to comment.