1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <title>Document</title>
- </head>
- <body>
- <input id="file" type="file" />
- <button id="upload">上传</button>
- <script src="https://gosspublic.alicdn.com/aliyun-oss-sdk-6.18.0.min.js"></script>
- <script>
- const client = new OSS({
-
- region: "oss-cn-hangzhou",
-
- accessKeyId: "STS.NV7VPCCHGfMPG5xFpdNLRQ8xY",
- accessKeySecret: "CJ4AeVxAfu7YZcynYAuG5neeoqYpx4TZJafNp3U8NoJ6",
-
- stsToken: "CAIS9AF1q6Ft5B2yfSjIr5WCHer3rpdm0Y+7RRPJonAxQsN+vv3Tuzz2IHhMfHdoCeAet/s0lGpY5vYflqZ5Qp5eRVHFbdY155hS8AX54hJsaA/sv9I+k5SANTW5KXyShb3/AYjQSNfaZY3eCTTtnTNyxr3XbCirW0ffX7SClZ9gaKZ8PGD6F00kYu1bPQx/ssQXGGLMPPK2SH7Qj3HXEVBjt3gX6wo9y9zmm53Du0uD1QWhmr5K9tSsGPX+MZkwZqUYesyuwel7epDG1CNt8BVQ/M909vccoW+Z5oHNWwAOuEXcY7qEr8cBNgZ8YbMhC0f/YkEOchsSGoABRXbZO3Bad6G/sxHKOwwOZRHsBlPNeKHc++JKUqsjtgDZ/SO67Z5dDjmCjVQ1fHN3Qme7vpvcJioxBE+ZbfovIrBLVvnP6UpktNg4h1FYLqj6ePdbGFtKhAbXTy6sWw4ed0bX/xiTQXx7jR0njhl9IaCgvxRWzDGrwmGn5ac84HEgAA==",
-
- bucket: "baishuihu",
- });
-
- let data;
-
-
-
-
- const upload = document.getElementById("upload");
- async function putObject(data) {
- try {
-
-
-
- const options = {
- meta: { temp: "demo" },
- mime: "json",
- headers: { "Content-Type": "text/plain" },
- };
- const result = await client.put("images/test.png", data, options);
- console.log(result);
- } catch (e) {
- console.log(e);
- }
- }
- upload.addEventListener("click", () => {
- const data = file.files[0];
- putObject(data);
- });
- </script>
- </body>
- </html>
|