PageSourceSearch

https://storagechain.io/assets/index-B41XlkWE.js

js storagechain.io collected 2026-10-03 21:04:01 UTC 13,535 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-CYUSluy9.js","assets/index-DID4Juaa.js","assets/index-BUpSYZsf.css"])))=>i.map(i=>d[i]);
2import{cX as ve,jW as je,k0 as ue,jX as ee,ik as c,ht as e,cl as H,gu as fe,iZ as Ne,fn as be,fP as we,bS as ge,bY as Z,iO as ke,fg as Me,f6 as Fe,by as oe,aI as Ae,bp as Ie}from"./index-DID4Juaa.js";import{I as O}from"./Input-CxEj0iYO.js";import{T as Ke}from"./Table-Blw0uhdD.js";let de=null;function me(){return de||(de=ve(()=>import("./browser-CYUSluy9.js").then(u=>u.b),__vite__mapDeps([0,1,2])).then(u=>u.default)),de}const Ce="_fileViewModal_12xsc_1",Ee="_table_12xsc_93",Pe="_encryptionModal_12xsc_100",_e="_fileProgress_12xsc_128",te={fileViewModal:Ce,table:Ee,encryptionModal:Pe,fileProgress:_e};function xe({s3Creds:u,s3Objects:a,setS3Objects:T,allS3Objects:P,selectedBucket:L,selectedFolder:se,setCurrentProcess:R,prefixes:S,setPrefixes:F,fetchingFilesLoading:p,hasMorePages:ne=!1,isLoadingMore:W=!1,onLoadMore:G}){var M;console.log("🚀 ~ S3ObjectTable ~ s3Objects:",L,se,R);const U=je(),N=ue(t=>t.queueReducer),m=ue(t=>t.fileReducer.filesUploadingProgress),[ae,X]=ee("s3Creds",{}),[A,I]=c.useState(!1),[K,le]=c.useState(!0),[i]=ee("accessToken",""),[x]=ee("passphrase",""),[r,B]=c.useState([]),[ie,z]=c.useState(""),[ce,D]=c.useState(!1),[v,re]=c.useState([]),[$,j]=c.useState(!1),q={true:"file is in queue. Please stay on this page until uploading completes.",false:"files are in queue. Please stay on this page until uploading completes."},d=t=>{const s=[...a];s[t].selected=!s[t].selected,T(s)},J=t=>t.split("/").pop()||"",Q=t=>{var h,n,g;const s=(g=(n=(h=J(t))==null?void 0:h.split("."))==null?void 0:n.pop())==null?void 0:g.toLowerCase();return Fe[s]||"application/octet-stream"},he=async t=>{var s,o;try{I(!0),console.log(" processedFilesFolder filesToUpload",t);const h=ke(t);console.log("🚀 ~ processedFilesFolder:",h);for(const n of h)if(((s=n==null?void 0:n.name)==null?void 0:s.split(".").pop())==="dat"||(n==null?void 0:n.type)==="application/dat"){const g=n,l=new FormData;l.append("file",g),l.append("path",n==null?void 0:n.path),await Me(i,l)}else U({type:"ADD_FILE",payload:{objectType:n==null?void 0:n.objectType,file:n.file,fileName:(o=n==null?void 0:n.name)==null?void 0:o.replace(" "," "),type:n==null?void 0:n.type,path:n==null?void 0:n.path}});return U({type:"START_PROCESS"}),I(!1),!0}catch(h){return console.error("Error in createFileAndFoldersObject:",h),I(!1),Z.error("Error processing files"),!1}},f=async()=>{try{if(!x)return Z.error("Please enter the passphrase first");j(!0);const t=a.filter(l=>l.selected);let s=[];t.forEach(l=>{var V;const Y=[...S.filter(C=>C),(V=l==null?void 0:l.key)==null?void 0:V.split("/").pop()].join("/");if(l.isFolder){const C=P.filter(y=>{var E;return(E=y==null?void 0:y.key)==null?void 0:E.startsWith(Y)});s=[...s,...C]}if(!(l!=null&&l.isFolder)){const C=P.find(y=>{var E;return(E=y==null?void 0:y.key)==null?void 0:E.startsWith(Y)});s.push({...C,selected:!0})}});const o=s==null?void 0:s.filter(l=>(l==null?void 0:l.size)!=="0 bytes");re(o);const h=await me(),n=new h.S3,{bucket:g}=u;return o.map(async l=>{I(!0);const Y={Bucket:g,Key:l.key};n.getSignedUrl("getObject",Y,async(V,C)=>{if(V)return console.error("Error generating pre-signed URL:",V),!1;const y=await fetch(C);if(!y.ok)throw new Error("Failed to download file");const E=await y.blob(),pe=Q(l==null?void 0:l.key),ye=new File([E],J(l.key),{type:pe});return B(Se=>[...Se,{file:ye,path:l.key}]),!0})}),!1}catch(t){return console.error("file: S3ObjectsTable.tsx:46 ~ handleUpload ~ err:",t),Z.error(t==null?void 0:t.message)}},b=()=>{le(!K)};c.useEffect(()=>{(()=>{try{const s=a.map(o=>({...o,selected:K}));T(s)}catch(s){console.error("handleSelectUnSelectAll ~ err:",s)}})()},[K]),c.useEffect(()=>{(()=>{if(N.queue.length>0){const s=N.queue.length-1;return s===0?z("Please wait, the final file in this folder is currently being uploaded."):(z(`${s} ${q[(s===1).toString()]}`),D(!0))}return N.queue.length||(I(!1),D(!1),$&&Z.success("Files Imported Successfully.")),N.queue.length===0?z("Please wait, the final file in this folder is currently being uploaded."):!1})()},[N]),c.useEffect(()=>{(()=>{(v==null?void 0:v.length)===(r==null?void 0:r.length)&&he(r)})()},[r==null?void 0:r.length]);const _=()=>{try{X({}),T([])}catch(t){console.error("handleChangeBucket ~ err:",t)}},w=t=>{F([...S,t==null?void 0:t.key])},k=t=>{const s=S.slice(0,t);return(s==null?void 0:s.length)===0?F([""]):F(s)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:"10px",paddingTop:"20px",width:"100%",maxHeight:"60vh",overflow:"auto"},children:[e.jsx("button",{className:"btn btn-secondary text-light fw-bold me-15",onClick:_,children:"Change Bucket"}),(a==null?void 0:a.length)===0&&p&&e.jsxs("div",{className:"d-flex align-items-center justfy-content-center gap-10 ff-poppins text-light fs-16",children:[e.jsx(H,{animation:"border",variant:"warning",size:"sm"}),"Fetching Files From S3-Bucket"]}),!p&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"d-flex align-items-center gap-10 ff-poppins text-light fs-16 ms-10",children:S==null?void 0:S.map((t,s)=>e.jsx("p",{onClick:()=>k(s),children:`> ${t||"Home"}`},t))}),e.jsxs("div",{className:`mainTable ${te.table}`,children:[e.jsxs(Ke,{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"sort",children:e.jsxs("div",{className:"d-flex align-items-center gap-10 pointer",onClick:b,children:[e.jsx("input",{type:"checkbox",checked:K}
2),"Select"]})}),e.jsx("th",{children:e.jsx("div",{className:"sort",id:"name",children:"Name"})}),e.jsx("th",{children:e.jsx("div",{className:"sort",id:"fileSize",children:"Size"})}),e.jsx("th",{children:e.jsx("div",{className:"sort",id:"updatedAt",children:"Updated date"})})]})}),e.jsxs("tbody",{children:[(a==null?void 0:a.length)!==0&&a.map((t,s)=>{var o;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("div",{className:"form-check",children:e.jsx("input",{className:"form-check-input",type:"checkbox",checked:t.selected,onChange:h=>{d(s)},id:"flexCheckIndeterminate"})})}),e.jsx("td",{children:e.jsxs("div",{className:"svgTitle",onClick:()=>t.isFolder?w(t):!1,children:[e.jsx("span",{className:"file-icon",children:fe(t!=null&&t.isFolder?"folder":t==null?void 0:t.key)}),Ne(t.key,12)]})}),e.jsx("td",{children:be(parseInt((o=t==null?void 0:t.size)==null?void 0:o.split("bytes")[0].trim()))}),e.jsx("td",{children:we(t.modifiedDate)})]},t.key)}),(a==null?void 0:a.length)===0&&!p&&e.jsx("td",{colSpan:8,className:"text-center",children:"No files found"})]})]}),ne&&e.jsx("div",{className:"d-flex justify-content-center my-3",children:e.jsx("button",{className:"btn btn-outline-light fw-bold rounded-pill",onClick:G,disabled:W,children:W?e.jsxs(e.Fragment,{children:[e.jsx(H,{animation:"border",variant:"warning",size:"sm"})," ","Loading more..."]}):"Load More"})})]})]}),e.jsxs("div",{className:"d-flex justify-content-center flex-column",children:[e.jsx("button",{type:"button",className:"btn btn-outline-light fw-bold rounded-pill me-2 flex-one",onClick:f,disabled:A,children:A?e.jsxs(e.Fragment,{children:[e.jsx(H,{animation:"border",variant:"warning",size:"sm"})," ","Importing to StorageChain"]}):"Import to StorageChain"}),A&&e.jsxs("div",{className:"d-flex flex-column align-items-center justify-content-center gap-10 mt-10",children:[e.jsxs("div",{className:"d-flex align-items-center justify-content-center gap-10",children:[e.jsx(H,{animation:"border",variant:"warning",size:"sm"}),e.jsx("p",{className:"ff-poppins text-light fs-16",children:"Fetching content from s3 bucket"})]}),e.jsxs("div",{className:"d-flex flex-fill flex-column",style:{width:"50%"},children:[e.jsx("p",{className:"fs-14 text-light text-start lh-base",children:(M=v[r==null?void 0:r.length])==null?void 0:M.key}),e.jsx(ge,{className:"my-2",variant:"yellow",now:Math.round(r.length*100/v.length)}),e.jsxs("div",{className:"d-flex align-items-center justify-content-between",children:[e.jsxs("p",{className:"fs-12 text-light text-start",children:[r.length," Files of ",v.length]}),e.jsxs("p",{className:"fs-12 text-light text-start",children:[(r.length*100/v.length).toFixed(2),"%"]})]})]})]}),e.jsx("div",{className:"text-warning mt-15",children:ce&&e.jsx("small",{children:ie})}),Object.keys(m).map(t=>e.jsxs("div",{className:te.fileProgress,children:[e.jsx("span",{className:"me-10",children:fe(m[t].name)}),e.jsxs("div",{className:"d-flex flex-fill flex-column",children:[e.jsx("p",{className:"fs-14 text-light text-start lh-base",children:m[t].name}),e.jsx(ge,{className:"my-2",variant:"yellow",now:Math.round(m[t].bytesUploaded*100/m[t].size)}),e.jsxs("div",{className:"d-flex align-items-center justify-content-between",children:[e.jsxs("p",{className:"fs-12 text-light text-start",children:[(m[t].bytesUploaded/1e6).toFixed(2)," ","MB of",` ${(m[t].size/1e6).toFixed(2)} MB`]}),e.jsxs("p",{className:"fs-12 text-light text-start",children:["Uploading...."," ",Math.round(m[t].bytesUploaded*100/m[t].size),"%"]})]})]})]},t))]})]})}xe.defaultProps={hasMorePages:!1,isLoadingMore:!1,onLoadMore:void 0};const Te={bucket:"",accessKeyId:"",secretAccessKey:"",region:""};function ze({...u}){const[a,T]=ee("s3Creds",Te),[P,L]=c.useState([]),[se,R]=c.useState([]),[S,F]=c.useState(!1),[p,ne]=c.useState([""]),[W,G]=c.useState(1),[U,N]=c.useState(!1),[m,ae]=c.useState(void 0),[X,A]=c.useState(!1),I=Ie,K=async(i,x=1)=>{var r;if(a!=null&&a.accessKeyId)try{const{accessKeyId:B,secretAccessKey:ie,region:z,bucket:ce}=a,D=await me();D.config.update({accessKeyId:B,secretAccessKey:ie,region:z});const v=new D.S3,re={Bucket:ce,Prefix:p.filter(d=>d).join("/"),MaxKeys:I,...i&&{ContinuationToken:i}},$=await v.listObjectsV2(re).promise(),j=[],q=[];(r=$.Contents)==null||r.forEach(d=>{const J={isFolder:!1,key:`${d.Key}`,size:`${d.Size} bytes`,modifiedDate:`${d.LastModified}`,object:d,selected:!1};q.push(J);const Q=(f,b,_)=>{(j==null?void 0:j.find(k=>{var M;return((M=k.key)==null?void 0:M.split(b)[0])===_}))||j.push({isFolder:!0,key:`${_}`,modifiedDate:`${f.LastModified}`,selected:!1,size:"0 bytes",object:void 0})};(f=>{var t,s,o,h,n;const b=`${p==null?void 0:p.filter(g=>g).join("/")}/`,_=(t=f.Key)==null?void 0:t.endsWith("/"),w=((s=f.Key)==null?void 0:s.split(b).filter(g=>g))||[],k=(h=(o=w[0])==null?void 0:o.split("/"))==null?void 0:h.filter(g=>g);if((k==null?void 0:k.length)>1)return Q(f,b,k[0]);if((w==null?void 0:w.length)===1&&!_)return j.push({isFolder:!1,key:`${f.Key}`,size:`${f.Size} bytes`,modifiedDate:`${f.LastModified}`,object:f,selected:!0});const M=(n=w[0])==null?void 0:n.split(b);return M?(Q(f,b,M[0]),!0):!1})(d)}),x===1?(L(j),R(q)):(L(d=>[...d,...j]),R(d=>[...d,...q])),N(!!$.NextContinuationToken),ae($.NextContinuationToken),A(!1)}catch(B){A(!1),console.error("file: index.tsx:42 ~ fetchS3Objects ~ err:",B)}},le=()=>{U&&!X&&(A(!0),G(i=>i+1),K(m,W+1))};return c.useEffect(()=>{a!=null&&a.accessKeyId&&(F(!0),G(1),ae(void 0),N(!1),K(void 0,1
2).finally(()=>{F(!1)}))},[a==null?void 0:a.accessKeyId,JSON.stringify(p)]),e.jsxs(oe,{...u,onHide:()=>{},size:"lg","aria-labelledby":"contained-modal-title-vcenter",centered:!0,className:P.length===0?te.encryptionModal:te.fileViewModal,children:[e.jsx(oe.Header,{onClick:()=>{u.onHide()},closeButton:!0,className:"p-30 pb-0 border-0",children:e.jsx("h5",{className:"text-light my-3 fw-bold mt-20 mb-3",children:"Initiate S3 Bucket"})}),e.jsx(oe.Body,{className:"p-30 pt-0 d-flex flex-column",style:{maxHeight:"70vh",overflow:"hidden"},children:P.length===0&&!(a!=null&&a.accessKeyId)?e.jsx("div",{children:e.jsx(Ae,{initialValues:{accessKeyId:"",secretAccessKey:"",region:"",bucket:""},onSubmit:i=>{F(!0),T(i)},children:i=>e.jsxs("form",{onSubmit:i.handleSubmit,className:"pt-30",children:[e.jsx(O,{name:"bucket",label:"Bucket name",type:"text",required:!0,placeholder:"Enter Bucket...",handleChange:x=>{i.setFieldValue("bucket",x.target.value)},value:i.values.bucket??"",error:i.errors.bucket}),e.jsx(O,{name:"accessKeyId",label:"AccessKey Id",type:"text",required:!0,placeholder:"Enter Access Key...",handleChange:x=>{i.setFieldValue("accessKeyId",x.target.value)},value:i.values.accessKeyId??"",error:i.errors.accessKeyId}),e.jsx(O,{name:"secretAccessKey",label:"Secret AccessKey",type:"text",required:!0,placeholder:"Enter Secret AccessKey...",handleChange:x=>{i.setFieldValue("secretAccessKey",x.target.value)},value:i.values.secretAccessKey??"",error:i.errors.secretAccessKey}),e.jsx(O,{name:"region",label:"Region",type:"text",required:!0,placeholder:"Enter Region...",handleChange:x=>{i.setFieldValue("region",x.target.value)},value:i.values.region??"",error:i.errors.region}),e.jsxs("div",{className:"d-flex align-items-center mt-40",children:[e.jsx("button",{type:"button",className:"btn btn-outline-light fw-bold rounded-pill me-2 flex-one",onClick:()=>u.onHide(),children:"Cancel"}),e.jsxs("button",{className:"btn btn-secondary rounded-pill text-light fw-bold flex-one",type:"submit",children:[S&&e.jsx(H,{animation:"border",variant:"warning",size:"sm"}),e.jsx("span",{children:"Initiate"})]})]})]})})}):e.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsx(xe,{selectedFolder:u.selectedFolder,selectedBucket:u.selectedBucket,s3Objects:P,s3Creds:a,setS3Objects:L,setCurrentProcess:u.setCurrentProcess,setPrefixes:ne,prefixes:p,allS3Objects:se,fetchingFilesLoading:S,hasMorePages:U,isLoadingMore:X,onLoadMore:le})})})})]})}export{ze as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.