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.
General conventions
- 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
savePathplus 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.
Cloud provider mapping
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.
| cloudService | Cloud provider | Section |
|---|---|---|
OSS | Alibaba Cloud Object Storage | Alibaba Cloud OSS |
AWS | Amazon S3 | AWS S3 |
KS3 | Kingsoft Cloud Object Storage | Kingsoft Cloud KS3 |
Alibaba Cloud OSS
| Reference | Link |
|---|---|
| Create a client with STS temporary credentials | Use temporary access credentials provided by STS to access OSS |
| Multipart upload | Multipart upload (Java) |
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 {
// Fill in the temporary access key and SecurityToken returned by the API
// Note: an AccessKeyId obtained from STS starts with "STS"
String accessKeyId = "yourSTSAccessKeyID";
String accessKeySecret = "yourSTSAccessKeySecret";
String stsToken = "yourSecurityToken";
String endpoint = "endpoint";
String region = "region";
String bucket = "bucket";
// key = savePath + relative file path
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); // Explicitly use the V4 signature algorithm
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();
}
}
}
AWS S3
| Reference | Link |
|---|---|
| Create a client with STS temporary credentials | Supply credentials explicitly |
| Upload (Java) | PutObject example |
| Upload (JS) | @aws-sdk/lib-storage |
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);
// Initialize the S3 client with the temporary credentials
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"));
}
Kingsoft Cloud KS3
| Reference | Link |
|---|---|
| Create a client with STS temporary credentials | KS3 temporary credentials |
| Multipart upload | KS3 upload |
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);
}
After the upload
Call Update Upload Status with status = 3; otherwise modeling will not start.
This chapter is from the official XGRIDS user manual. Official source (opens in a new tab) · Updated:

