* here.
*/
virtual int list_objects(std::string& id, std::string& bucket, int max, std::string& prefix, std::string& delim,
- std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes) = 0;
+ std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes,
+ bool get_content_type) = 0;
/** Create a new bucket*/
virtual int create_bucket(std::string& id, std::string& bucket, map<std::string, bufferlist>& attrs, uint64_t auid=0) = 0;
#define RGW_FORMAT_XML 1
#define RGW_FORMAT_JSON 2
+#define RGW_REST_OPENSTACK 0x1
+#define RGW_REST_OPENSTACK_AUTH 0x2
+
#define CGI_PRINTF(state, format, ...) do { \
int __ret = FCGX_FPrintF(state->fcgx->out, format, __VA_ARGS__); \
if (state->header_ended) \
time_t mtime;
// two md5 digests and a terminator
char etag[ceph::crypto::MD5::DIGESTSIZE * 2 + 1];
-
- void encode(bufferlist& bl) const {
- __u8 struct_v = 1;
- ::encode(struct_v, bl);
- uint64_t s = size;
- __u32 mt = mtime;
- ::encode(name, bl);
- ::encode(s, bl);
- ::encode(mt, bl);
- }
- void decode(bufferlist::iterator& bl) {
- __u8 struct_v;
- ::decode(struct_v, bl);
- __u32 mt;
- uint64_t s;
- ::decode(name, bl);
- ::decode(s, bl);
- ::decode(mt, bl);
- size = s;
- mtime = mt;
- }
+ string content_type;
};
-WRITE_CLASS_ENCODER(RGWObjEnt)
/** Store basic data on an object */
struct RGWBucketEnt {
}
int RGWFS::list_objects(string& id, string& bucket, int max, string& prefix, string& delim,
- string& marker, vector<RGWObjEnt>& result, map<string, bool>& common_prefixes)
+ string& marker, vector<RGWObjEnt>& result, map<string, bool>& common_prefixes,
+ bool get_content_type)
{
map<string, bool> dir_map;
char path[BUF_SIZE];
int list_buckets_next(std::string& id, RGWObjEnt& obj, RGWAccessHandle *handle);
int list_objects(std::string& id, std::string& bucket, int max, std::string& prefix, std::string& delim,
- std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes);
+ std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes,
+ bool get_content_type);
int create_bucket(std::string& id, std::string& bucket, map<std::string, bufferlist>& attrs, uint64_t auid=0);
int put_obj_meta(std::string& id, std::string& bucket, std::string& obj, time_t *mtime,
}
url_decode(s->args.get("delimiter"), delimiter);
- ret = rgwstore->list_objects(s->user.user_id, s->bucket_str, max, prefix, delimiter, marker, objs, common_prefixes);
+ ret = rgwstore->list_objects(s->user.user_id, s->bucket_str, max, prefix, delimiter, marker, objs, common_prefixes,
+ !!(s->prot_flags & RGW_REST_OPENSTACK));
done:
send_response();
}
struct req_state;
-#define RGW_REST_OPENSTACK 0x1
-#define RGW_REST_OPENSTACK_AUTH 0x2
-
/** Get the HTTP request metadata */
extern void get_request_metadata(struct req_state *s, map<string, bufferlist>& attrs);
/**
* here.
*/
int RGWRados::list_objects(string& id, string& bucket, int max, string& prefix, string& delim,
- string& marker, vector<RGWObjEnt>& result, map<string, bool>& common_prefixes)
+ string& marker, vector<RGWObjEnt>& result, map<string, bool>& common_prefixes,
+ bool get_content_type)
{
librados::IoCtx io_ctx;
int r = rados->ioctx_create(bucket.c_str(), io_ctx);
strncpy(obj.etag, bl.c_str(), sizeof(obj.etag));
obj.etag[sizeof(obj.etag)-1] = '\0';
}
+ if (get_content_type) {
+ bl.clear();
+ obj.content_type = "";
+ if (io_ctx.getxattr(*p, RGW_ATTR_CONTENT_TYPE, bl) >= 0) {
+ obj.content_type = bl.c_str();
+ }
+ }
result.push_back(obj);
}
/** get listing of the objects in a bucket */
virtual int list_objects(std::string& id, std::string& bucket, int max, std::string& prefix, std::string& delim,
- std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes);
+ std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes,
+ bool get_content_type);
/**
* create a bucket with name bucket and the given list of attrs
s->formatter->dump_value_str("name", iter->name.c_str());
s->formatter->dump_value_str("hash", ""%s"", iter->etag);
s->formatter->dump_value_int("bytes", "%lld", iter->size);
+ if (iter->content_type.size())
+ s->formatter->dump_value_str("content_type", iter->content_type.c_str());
dump_time(s, "last_modified", &iter->mtime);
s->formatter->close_section("object");
}