Gebruik na het aanroepen van Taak aanmaken en uploadreferenties ophalen of Uploadreferenties opnieuw ophalen de tijdelijke referenties in data.params om de invoergegevens voor het modelleren te uploaden.
- Gebruik voor alle uploads een upload in delen (multipart upload).
- Volg voor het gebruik van tijdelijke uploadreferenties de officiële documentatie van de betreffende cloudprovider.
- Het maximale aantal delen is 10.000. Bereken bij grote bestanden de grootte per deel op basis van de totale grootte, zodat je de limiet niet overschrijdt.
- De uiteindelijke bestands-Key is
savePath plus het relatieve pad van het bestand. - Tijdelijke referenties zijn standaard 12 uur geldig. Roep na verloop Uploadreferenties opnieuw ophalen aan om ze te vernieuwen.
De waarde data.params.cloudService in de respons bepaalt welke SDK je gebruikt. Elke integrator werkt normaal met één vaste cloudprovider, dus je hoeft ze niet allemaal te ondersteunen.
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);
}
Roep Uploadstatus bijwerken aan met status = 3; anders start het modelleren niet.