diff --git a/src/ObjectList.tsx b/src/ObjectList.tsx index 7dcb264..f981c05 100644 --- a/src/ObjectList.tsx +++ b/src/ObjectList.tsx @@ -9,12 +9,14 @@ type Props = { }; type State = { + loaded: boolean; folders: string[]; files: string[]; }; class ObjectList extends React.Component { state = { + loaded: false, folders: [], files: [], }; @@ -32,23 +34,52 @@ class ObjectList extends React.Component { Delimiter: '/', }); try { + const pxlen = this.props.prefix.length; + const data = await this.props.client.send(command); console.log("ok", data); this.setState({ - folders: (data.CommonPrefixes || []).map((cp) => cp.Prefix!), - files: (data.Contents || []).map((obj) => obj.Key!), + loaded: true, + folders: (data.CommonPrefixes || []).map((cp) => cp.Prefix!.substring(pxlen)), + files: (data.Contents || []).map((obj) => obj.Key!.substring(pxlen)), }); } catch(error) { console.log("err", error); } } + parentTag() { + let spl = this.props.prefix.split("/"); + while (spl.pop() == ""); + spl.push(""); + let pp = spl.join("/"); + return ( +
  • + .. +
  • + ); + } + render() { + let par = (this.props.prefix.length > 0 ? + this.parentTag() + : <>); + + if (!this.state.loaded) { + return ( + + ); + } + return (