Utilizzo del proxy Data Access Service (DAS) per accedere agli archivi S3 e S3 compatibili
Applicazioni esterne e motori di interrogazione possono accedere agli archivi compatibili S3 e S3 gestiti da watsonx.data attraverso il proxy DAS.
La funzione proxy del Data Access Service (DAS) è stata completamente rimossa in 2.1.2 e non è più disponibile in watsonx.data. Non è possibile utilizzare la funzione proxy del Data Access Service (DAS) per accedere all'archiviazione degli oggetti ( S3, ADLS e ABS).
Per accedere agli archivi compatibili S3 e S3:
-
Ottenere l'endpoint DAS dalla finestra informativa watsonx.data. Clicca il
isull'icona nella home page per aprire la finestra delle informazioni. -
Sostituire l'endpoint S3 con l'endpoint DAS nel codice Java.
<DAS endpoint>/cas/v1/proxy -
Sostituire la chiave di accesso con il valore codificato nel codice Java come segue:
base64{<crn>|Basic base64{ibmlhapikey_<user_id>:<IAM_APIKEY>}}Prendere ilBase64 stringa codificata, utilizzare uno dei seguenti comandi:
printf "username:<apikey>" | base64echo -n "username:<apikey>" | base64
Java per utilizzare DAS
String bucketName = "bucket1";
String keyName = "folder1/file1";
# replace the target object store endpoint with the DAS proxy endpoint
String endpoint = "<DAS endpoint get from About page>/cas/v1/proxy";
/** Replace the Access Key with watsonx.data user name and API key following the below base64 encoded method.
* For Cloud Pak for Data: base64{<instanceid>|ZenAPIkey base64{username:<apikey>}}
* For IBM Cloud: base64{<crn>|Basic base64{ibmlhapikey_<user_id>:<IAM_APIKEY>}}
* For AWS: base64{<crn>|Basic base64{ibmlhapikey_ServiceId-<service_id>:<APIKEY>}}
*/
String accessKey = "encoded value";
String secretKey = "any string";
BasicAWSCredentials cos_cred = new BasicAWSCredentials(accessKey, secretKey);
EndpointConfiguration cosEndPoint = new EndpointConfiguration(endpoint, "us-east");
AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withPathStyleAccessEnabled(true)
.withCredentials(new AWSStaticCredentialsProvider(cos_cred))
.withEndpointConfiguration(cosEndPoint).build();
GetObject.GetObjectTest(s3Client, bucketName, keyName);
Per informazioni suS3 Autorizzazioni API REST, vedere S3 Autorizzazioni API REST.