Skip to content
TREN
Atlıhan Harita

Structured Spatial Modeling User Manual

Temporary Upload Credentials

Chapter 04 / 05Manual version v1.0.0.0English

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 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.

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.

cloudServiceCloud providerSection
OSSAlibaba Cloud Object StorageAlibaba Cloud OSS
AWSAmazon S3AWS S3
KS3Kingsoft Cloud Object StorageKingsoft Cloud KS3

Alibaba Cloud OSS

ReferenceLink
Create a client with STS temporary credentialsUse temporary access credentials provided by STS to access OSS
Multipart uploadMultipart 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

ReferenceLink
Create a client with STS temporary credentialsSupply 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

ReferenceLink
Create a client with STS temporary credentialsKS3 temporary credentials
Multipart uploadKS3 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:

XGRIDS Türkiye

We're With You During Setup and in the Field

Atlıhan Harita provides training and technical support for device setup, firmware updates, software use, and field applications. Send us your question and our specialist will get back to you.

+90 216 546 0804