PageSourceSearch

https://www.modernliving.jp/_assets/fre/scopes/hdm/_next/static/ch…/demos/s3-presigned-url-2e2e9c98736529d5.js

js modernliving.jp collected 2026-09-26 02:39:30 UTC 3,221 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[48137],{75408:(e,t,l)=>{"use strict";l.r(t),l.d(t,{__N_SSP:()=>s,default:()=>i});var n=l(71055),r=l(9954),a=l(71055),s=!0;function i(){let{0:e,1:t}=(0,n.useState)(null),{0:l,1:s}=(0,n.useState)("uploads/test-upload.png"),{0:i,1:u}=(0,n.useState)(""),{0:o,1:d}=(0,n.useState)({message:"",type:""}),{0:p,1:c}=(0,n.useState)(!1),{0:g,1:f}=(0,n.useState)(!1),y=(0,n.useRef)(null),Y=(e,t)=>{d({message:e,type:t})},h=async()=>{if(!e)return void Y("Please select a file first","error");if(!l.trim())return void Y("Please enter a valid S3 key","error");c(!0),Y("Generating presigned URL...","info");try{let t=await fetch("/api/presigned-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:l,contentType:e.type||"application/octet-stream"})});if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.json();u(n.url),Y("Presigned URL generated successfully! You can now upload the file.","success")}catch(e){Y(`Error generating presigned URL: ${e.message}`,"error")}finally{c(!1)}},m=async()=>{if(!e)return void Y("Please select a file first","error");if(!i)return void Y("Please generate a presigned URL first","error");f(!0),Y("Uploading file...","info");try{let t=await fetch(i,{method:"PUT",headers:{"Content-Type":e.type||"application/octet-stream"},body:e});if(f(!1),t.ok)Y("File uploaded successfully! \uD83C\uDF89","success");else{let e=await t.text().catch(()=>"Unable to read error response");Y(`Upload failed: ${e}, ${t.status} ${t.statusText}`,"error")}}catch(e){f(!1),Y(`Upload error: ${e.message}`,"error")}};return(0,r.Y)(a.Fragment,null,(0,r.Y)("div",null,(0,r.Y)("h1",null,"\uD83D\uDE80 S3 Presigned URL Upload Demo"),(0,r.Y)("div",null,(0,r.Y)("label",{htmlFor:"keyInput"},"S3 Key (file path in bucket):"),(0,r.Y)("input",{type:"text",id:"keyInput",value:l,onChange:e=>s(e.target.value),placeholder:"uploads/my-file.jpg"})),(0,r.Y)("div",null,(0,r.Y)("label",{htmlFor:"fileInput"},"Select File to Upload:"),(0,r.Y)("input",{type:"file",id:"fileInput",ref:y,onChange:e=>{let n=e.target.files[0];t(n),n&&s((l.substring(0,l.lastIndexOf("/")+1)||"uploads/")+n.name)},accept:"image/*"}),e?(0,r.Y)("div",null,(0,r.Y)("strong",null,"Selected File:"),(0,r.Y)("br",null),"Name: ",e.name,(0,r.Y)("br",null),"Size: ",(e.size/1024/1024).toFixed(2)," MB",(0,r.Y)("br",null),"Type: ",e.type):null),(0,r.Y)("div",null,(0,r.Y)("button",{onClick:h,disabled:p},p?"Generating...":"1. Generate Presigned URL"),(0,r.Y)("button",{onClick:m,disabled:!i||g},g?"Uploading...":"2. Upload File"),(0,r.Y)("button",{onClick:()=>{t(null),s("uploads/test-upload.png"),u(""),d({message:"",type:""}),y.current&&(y.current.value="")}},"Reset")),g?(0,r.Y)("div",null,(0,r.Y)("div",null,"Uploading file...")):null,o.message?(0,r.Y)("div",null,(0,r.Y)("p",null,(0,r.Y)("strong",null,"Status (",o.type,"):")," ",o.message),i&&"success"===o.type?(0,r.Y)("div",null,(0,r.Y)("strong",null,"Presigned URL:"),(0,r.Y)("br",null),(0,r.Y)("code",null,i)):null):null))}},76801:(e,t,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/demos/s3-presigned-url",function(){return l(75408)}])}},e=>{e.O(0,[46593,90636,38792],()=>e(e.s=76801)),_N_E=e.O()}]);

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.