After calling Create Task and Get Upload Credentials or Get Upload Credentials Again, use the temporary credentials in data.params to upload the modeling input data.
- Use multipart upload for all uploads.
- For how to use temporary upload credentials, follow the official documentation of the specific cloud provider.
- The maximum number of parts is 10,000. For large files, calculate the part size from the total size so you do not exceed the limit.
- The final file Key is
savePath plus the file's relative path. - Temporary credentials are valid for 12 hours by default. After they expire, call Get Upload Credentials Again to renew them.
The data.params.cloudService value in the response determines which SDK to use. Each integrator normally works with only one fixed cloud provider, so you do not need to support all of them.
import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.CredentialsProvider;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.model.PutObjectRequest;
import com.aliyun.oss.model.PutObjectResult;
import java.io.File;
public class Demo {
public static void main(String[] args) throws Exception {
String accessKeyId = "yourSTSAccessKeyID";
String accessKeySecret = "yourSTSAccessKeySecret";
String stsToken = "yourSecurityToken";
String endpoint = "endpoint";
String region = "region";
String bucket = "bucket";
String key = "prd/spatial-model/{accountId}/{taskCode}/input/render2/info/poses.json";
CredentialsProvider credentialsProvider =
new DefaultCredentialProvider(accessKeyId, accessKeySecret, stsToken);
ClientBuilderConfiguration conf = new ClientBuilderConfiguration();
conf.setSignatureVersion(SignVersion.V4);
OSS ossClient = OSSClientBuilder.create()
.endpoint(endpoint)
.credentialsProvider(credentialsProvider)
.clientConfiguration(conf)
.region(region)
.build();
try {
PutObjectRequest req =
new PutObjectRequest(bucket, key, new File("D:\\localpath\\poses.json"));
PutObjectResult result = ossClient.putObject(req);
} catch (OSSException oe) {
System.out.println("Error Message:" + oe.getErrorMessage());
System.out.println("Error Code:" + oe.getErrorCode());
System.out.println("Request ID:" + oe.getRequestId());
} catch (ClientException ce) {
System.out.println("Error Message:" + ce.getMessage());
} finally {
if (ossClient != null) ossClient.shutdown();
}
}
}
public static void main(String[] args) throws Exception {
String accessKeyId = "yourSTSAccessKeyID";
String accessKeySecret = "yourSTSAccessKeySecret";
String securityToken = "yourSecurityToken";
String region = "region";
String bucket = "bucket";
String key = "prd/spatial-model/{accountId}/{taskCode}/input/render2/info/poses.json";
AwsSessionCredentials sessionCredentials = AwsSessionCredentials.create(
accessKeyId, accessKeySecret, securityToken);
S3Client s3Client = S3Client.builder()
.region(Region.of(region))
.credentialsProvider(StaticCredentialsProvider.create(sessionCredentials))
.build();
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
.bucket(bucket)
.key(key)
.build();
s3Client.putObject(putObjectRequest, java.nio.file.Paths.get("D:\\resource\\poses.json"));
}
public Ks3Client initKs3Client() {
String accessKeyId = "yourSTSAccessKeyID";
String accessKeySecret = "yourSTSAccessKeySecret";
String securityToken = "yourSecurityToken";
String endpoint = "yourEndpoint";
String region = "region";
Ks3ClientConfig config = new Ks3ClientConfig();
config.setEndpoint(endpoint);
config.setRegion(Region.valueOf(region));
config.setProtocol(Ks3ClientConfig.PROTOCOL.http);
config.setHttpClientConfig(new HttpClientConfig());
return new Ks3Client(accessKeyId, accessKeySecret, securityToken, config);
}
Call Update Upload Status with status = 3; otherwise modeling will not start.