jclouds:如何更新现有Blob的元数据? [英] jclouds : how do I update metadata for an existing blob?

查看:78
本文介绍了jclouds:如何更新现有Blob的元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Rackspace的Cloud Files中有数千个Blob,我需要为其更新内容类型.但是,我无法弄清楚如何使用jclouds API做到这一点.

I've got a few thousand blobs at Rackspace's Cloud Files which I need to update content type for. However, I can't figure out how I do that using the jclouds API.

如何更新现有Blob上的元数据?

How can I go about to update metadata on an existing blob?

推荐答案

假设您已经为机架空间运行了整个设置,那么使用jclouds很简单:

Assuming you have the whole set up running for your rackspace, using jclouds is easy:

首先使用以下详细信息进行初始化:

First initialize with the following details:

    BlobStoreContext context = ContextBuilder.newBuilder(provider)
            .credentials(username, apiKey)
            .buildView(BlobStoreContext.class);

    BlobStore blobStore = context.getBlobStore();

您现在可以构建一个新的Blob来放置机架空间:

You can now build a new blob to to put on rackspace:

Blob blob = blobStore.blobBuilder(键) .userMetadata(元数据) .payload(值) .build();

Blob blob = blobStore.blobBuilder(key) .userMetadata(metadata) .payload(value) .build();

blobStore.putBlob(container, blob);

value是输入的bytes [],元数据是与blob之类的内容类型相关联的元数据的哈希图.

value is the input bytes[] and metadata is a hash map of meta data associated with the blob like content type.

如果要执行更新之类的操作,请执行以下操作:

If you want to do operations like update:

RegionScopedBlobStoreContext context = ContextBuilder.newBuilder("openstack-swift")
                                .endpoint(config.getAuthUrl())
                                .credentials(config.getUser(), config.getPasswd())
                                .overrides(p)
                                .buildView(RegionScopedBlobStoreContext.class);
SwiftApi swift = (SwiftApi) ((org.jclouds.rest.internal.ApiContextImpl)context.unwrap()).getApi();

boolean success = swift.objectApiInRegionForContainer(config.getRegion(), container).updateMetadata(filename, metaData);

我知道这是一个概述,但我希望它能为您提供一个良好的指导.

I know it is an overview but I hope it gives you a good direction.

这篇关于jclouds:如何更新现有Blob的元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆