本文整理汇总了Java中org.javaswift.joss.model.StoredObject.downloadObject方法的典型用法代码示例。如果您正苦于以下问题:Java StoredObject.downloadObject方法的具体用法?Java StoredObject.downloadObject怎么用?Java StoredObject.downloadObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javaswift.joss.model.StoredObject
的用法示例。
在下文中一共展示了StoredObject.downloadObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFile
import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
@Override
public void getFile(File file, String path) throws IOException {
if (path.startsWith("/") && path.length() > 1) {
path = path.substring(1);
}
StoredObject object = container.getObject(path);
object.downloadObject(file);
object.reload();
}
示例2: example
import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
private static void example() {
// Create a Connection
AccountConfig config = new AccountConfig();
config.setUsername(username);
config.setPassword(password);
config.setAuthUrl(authUrl);
config.setAuthenticationMethod(AuthenticationMethod.BASIC);
Account account = new AccountFactory(config).createAccount();
// Create a Container
Container container = account.getContainer("my-new-container");
container.create();
// Create an Object
StoredObject object = container.getObject("foo.txt");
object.uploadObject(new File("src/test/resources/foo.txt"));
// Add/Update Object Metadata
Map<String, Object> metadata = new TreeMap<String, Object>();
metadata.put("key", "value");
object.setMetadata(metadata);
// List Owned Containers
Collection<Container> containers = account.list();
for (Container currentContainer : containers) {
System.out.println(currentContainer.getName());
}
// List a Container's Content
Collection<StoredObject> objects = container.list();
for (StoredObject currentObject : objects) {
System.out.println(currentObject.getName());
}
// Retrieve an Object's Metadata
Map<String, Object> returnedMetadata = object.getMetadata();
for (String name : returnedMetadata.keySet()) {
System.out.println("META / " + name + ": " + returnedMetadata.get(name));
}
// Retrieve an Object
object.downloadObject(new File("/tmp/outfile.txt"));
// Delete an Object
object.delete();
// Delete a Container
container.delete();
}