diff --git a/src/ObjectInfo.tsx b/src/ObjectInfo.tsx index 136cae9..4a7195e 100644 --- a/src/ObjectInfo.tsx +++ b/src/ObjectInfo.tsx @@ -7,6 +7,7 @@ import Modal from 'react-bootstrap/Modal'; import { BsFileEarmarkText, BsDownload } from 'react-icons/bs'; import downloadFile from './downloadFile'; +import fileSizePretty from './fileSizePretty'; type Props = { client: S3Client; @@ -64,7 +65,7 @@ class ObjectInfo extends React.Component {

Key: { this.props.s3key }

{ this.state.loaded ? <> -

Size: { this.state.size }

+

Size: { fileSizePretty(this.state.size) }

Content type: { this.state.contentType }

: <> } diff --git a/src/ObjectList.tsx b/src/ObjectList.tsx index 0492a5b..002fa50 100644 --- a/src/ObjectList.tsx +++ b/src/ObjectList.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { Link, useParams } from 'react-router-dom'; -import { S3Client, ListObjectsV2Command, GetObjectCommand } from '@aws-sdk/client-s3'; +import { S3Client, ListObjectsV2Command, GetObjectCommand, DeleteObjectCommand } from '@aws-sdk/client-s3'; import Alert from 'react-bootstrap/Alert'; import Breadcrumb from 'react-bootstrap/Breadcrumb'; @@ -15,7 +15,8 @@ import ObjectInfo from './ObjectInfo'; import UploadFiles from './UploadFiles'; import downloadFile from './downloadFile'; -import { BsFolder, BsFileEarmarkText, BsDownload } from 'react-icons/bs'; +import { BsInfoCircle, BsFolder, BsFileEarmarkText, BsDownload } from 'react-icons/bs'; +import { AiOutlineDelete } from 'react-icons/ai'; type Props = { client: S3Client; @@ -129,6 +130,18 @@ class ObjectList extends React.Component { this.setState({info: f, iInfo: this.state.iInfo + 1}); } + async deleteFile(f: string) { + if (window.confirm("Really delete file " + f + "?")) { + console.log("DELETING", f); + let command = new DeleteObjectCommand({ + Bucket: this.props.bucket, + Key: this.props.prefix + f, + }); + let res = await this.props.client.send(command); + this.loadEntries(); + } + } + openUpload() { this.setState({iUpload: this.state.iUpload + 1}); } @@ -187,16 +200,28 @@ class ObjectList extends React.Component { )} { this.state.files.map((f) => - this.openInfo(f)}> +
{ f }
- + +