When you access objects in Object Storage Service (OSS) by using a client, especially a client on which traffic throttling is difficult to implement, a large amount of bandwidth of OSS may be occupied, which obstructs other applications from accessing OSS. To prevent this issue, you can use the single-connection bandwidth throttling feature that is provided by OSS to throttle the bandwidth for object downloads. This way, sufficient bandwidth can be reserved for other applications to access OSS.
- When you use packaging tools such as Webpack and Browserify, install OSS SDK for Browser.js by running the npm install ali-oss command.
- In most cases, OSS SDK for Browser.js is used in browsers. To prevent your AccessKey pair from being exposed, we recommend that you use temporary access credentials obtained from Security Token Service (STS) to access OSS.
For more information about how to use STS, see Use temporary credentials provided by STS to access OSS in OSS Developer Guide. You can call the AssumeRole operation or use STS SDKs for various programming languages to obtain temporary access credentials. Temporary access credentials include a security token and a temporary AccessKey pair that consists of an AccessKey ID and an AccessKey secret.
The following code provides an example on how to configure bandwidth throttling when you download an object by using a signed URL:
For more information about the complete sample code of single-connection bandwidth throttling, visit GitHub.