use of com.aliyun.oss.model.CreateSymlinkRequest in project aliyun-oss-java-sdk by aliyun.
the class SymlinkTest method testNormalCreateSymlink.
@Test
public void testNormalCreateSymlink() {
final String symLink = "normal-create-sym-link";
try {
ossClient.putObject(bucketName, targetObject, new ByteArrayInputStream(content.getBytes()));
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentType("text/plain");
metadata.addUserMetadata("property", "property-value");
CreateSymlinkRequest createSymlinkRequest = new CreateSymlinkRequest(bucketName, symLink, targetObject);
createSymlinkRequest.setMetadata(metadata);
ossClient.createSymlink(createSymlinkRequest);
OSSSymlink symbolicLink = ossClient.getSymlink(bucketName, symLink);
Assert.assertEquals(symbolicLink.getSymlink(), symLink);
Assert.assertEquals(symbolicLink.getTarget(), targetObject);
Assert.assertEquals(symbolicLink.getMetadata().getContentType(), "text/plain");
Assert.assertEquals(symbolicLink.getMetadata().getUserMetadata().get("property"), "property-value");
Assert.assertEquals(symbolicLink.getRequestId().length(), REQUEST_ID_LEN);
ossClient.deleteObject(bucketName, symLink);
ossClient.deleteObject(bucketName, targetObject);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
Aggregations