use of com.aliyun.oss.model.OSSSymlink in project aliyun-oss-java-sdk by aliyun.
the class SymlinkTest method testNormalCreateSymlinkChar.
@Test
public void testNormalCreateSymlinkChar() {
final String symLink = "normal-create-sym-link-[]< >=-?/世界/中国.txt";
try {
ossClient.putObject(bucketName, targetObject, new ByteArrayInputStream(content.getBytes()));
ossClient.createSymlink(bucketName, symLink, targetObject);
OSSSymlink symbolicLink = ossClient.getSymlink(bucketName, symLink);
Assert.assertEquals(symbolicLink.getSymlink(), symLink);
Assert.assertEquals(symbolicLink.getTarget(), targetObject);
Assert.assertEquals(symbolicLink.getRequestId().length(), REQUEST_ID_LEN);
ossClient.deleteObject(bucketName, symLink);
ossClient.deleteObject(bucketName, targetObject);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
use of com.aliyun.oss.model.OSSSymlink in project aliyun-oss-java-sdk by aliyun.
the class OSSObjectOperation method getSymlink.
public OSSSymlink getSymlink(GenericRequest genericRequest) throws OSSException, ClientException {
assertParameterNotNull(genericRequest, "genericRequest");
String bucketName = genericRequest.getBucketName();
String symlink = genericRequest.getKey();
assertParameterNotNull(bucketName, "bucketName");
assertParameterNotNull(symlink, "symlink");
ensureBucketNameValid(bucketName);
ensureObjectKeyValid(symlink);
Map<String, String> params = new HashMap<String, String>();
params.put(SUBRESOURCE_SYMLINK, null);
RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.GET).setBucket(bucketName).setKey(symlink).setParameters(params).setOriginalRequest(genericRequest).build();
OSSSymlink symbolicLink = doOperation(request, getSymbolicLinkResponseParser, bucketName, symlink, true);
if (symbolicLink != null) {
symbolicLink.setSymlink(new String(symlink));
}
return symbolicLink;
}
Aggregations