<meta charset="UTF-8" />
<button id="upload">Upload</button>
<button id="download">Download</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 name = 'exampledir/range.txt';
const upload = document.getElementById('upload');
upload.addEventListener('click', async () => {
const data = document.getElementById('file').files[0];
const partSize = 5 * 1024 * 1024;
await client.uploadFile({
const download = document.getElementById('download');
download.addEventListener('click', async () => {
const result = await client.getObjectV2({
headers: { Range: 'bytes=0-9' },
const blob = result.data.content;
const link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = 'getobjectv2.txt';
window.URL.revokeObjectURL(link.href);