<meta charset="UTF-8" />
<button id="upload">Upload</button>
<input id="file" type="file" />
<script src="https://tos-public.volccdn.com/obj/volc-tos-public/@volcengine/tos-sdk@latest/browser/tos.umd.production.min.js"></script>
<script type="text/javascript">
const client = new TOS({
accessKeyId: yourAccessKey,
accessKeySecret: yourSecretKey,
stsToken: yourSecurityToken,
const upload = document.getElementById('upload');
upload.addEventListener('click', async () => {
const file = document.getElementById('file').files[0];
const name = 'exampledir/partUploadObject.txt';
} = await client.createMultipartUpload({
const PART_SIZE = 8 * 1024 * 1024;
const uploadPartRes = [];
for (let i = 0; i * PART_SIZE < file.size; ++i) {
const { data } = await client.uploadPart({
body: file.slice(i * PART_SIZE, Math.min((i + 1) * PART_SIZE, file.size)),
uploadPartRes[i] = data.ETag;
await client.completeMultipartUpload({
parts: uploadPartRes.map((eTag, idx) => ({
await client.abortMultipartUpload({