You signed in with another tab or window.Reloadto refresh your session.You signed out in another tab or window.Reloadto refresh your session.You switched accounts on another tab or window.Reloadto refresh your session.Dismiss alert
// Set yourEndpoint to the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set yourEndpoint to https://oss-cn-hangzhou.aliyuncs.com.
Stringendpoint="yourEndpoint";
// Specify the temporary AccessKey pair obtained from STS.
StringaccessKeyId="yourAccessKeyId";
StringaccessKeySecret="yourAccessKeySecret";
// Specify the security token obtained from STS.
StringsecurityToken="yourSecurityToken";
// Specify the name of the bucket in which the object you want to access is stored. Example: examplebucket.
//String bucketName = "examplebucket";
// Specify the full path of the object. Example: exampleobject.txt. The full path of the object cannot contain bucket names.
//String objectName = "exampleobject.txt";
// You can use the AccessKey pair and security token contained in the temporary access credential obtained from STS to create an OSSClient.
// Perform operations on OSS resources, such as upload or download objects.
// Upload an object. In this example, a local file is uploaded to OSS as an object.
// Specify the full path of the local file to upload. If the path of the local file is not specified, the file is uploaded to the path of the project to which the sample program belongs.
//PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, new File("D:\\localpath\\examplefile.txt"));
//ossClient.putObject(putObjectRequest);
// Download an object to your local computer. If the specified local file already exists, the file is replaced by the downloaded object. If the specified local file does not exist, the local file is created.
// If the path for the object is not specified, the downloaded object is saved to the path of the project to which the sample program belongs.
//ossClient.getObject(new GetObjectRequest(bucketName, objectName), new File("D:\\localpath\\examplefile.txt"));
// Shut down the OSSClient instance.
ossClient.shutdown();
}
privatestaticvoidcreateSignedUrl(OSSossClient) {
// Set yourEndpoint to the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set yourEndpoint to https://oss-cn-hangzhou.aliyuncs.com.
Stringendpoint="yourEndpoint";
// Specify the temporary AccessKey pair obtained from STS.
StringaccessKeyId="yourAccessKeyId";
StringaccessKeySecret="yourAccessKeySecret";
// Specify the security token obtained from STS.
StringsecurityToken="yourSecurityToken";
// Specify the name of the bucket in which the object you want to access is stored. Example: examplebucket.
StringbucketName="examplebucket";
// Specify the full path of the object. Example: exampleobject.txt. The full path of the object cannot contain bucket names.
// Set yourEndpoint to the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set yourEndpoint to https://oss-cn-hangzhou.aliyuncs.com.
Stringendpoint="yourEndpoint";
// Specify the temporary AccessKey pair obtained from STS.
StringaccessKeyId="yourAccessKeyId";
StringaccessKeySecret="yourAccessKeySecret";
// Specify the security token obtained from STS.
StringsecurityToken="yourSecurityToken";
// Specify the name of the bucket in which the object you want to access is stored. Example: examplebucket.
StringbucketName="examplebucket";
// Specify the full path of the object. Example: exampleobject.txt. The full path of the object cannot contain bucket names.
StringobjectName="exampleobject.txt";
// You can use the AccessKey pair and security token contained in the temporary access credential obtained from STS to create an OSSClient.