#define USER_INFO_VER 2
+#define RGW_MAX_CHUNK_SIZE (4*1024*1024)
+
typedef void *RGWAccessHandle;
/** Store error returns for output at a different point in the program */
}
MD5_Init(&c);
- MD5_Update(&c, data, (unsigned long)len);
+ do {
+ get_data();
+ if (len > 0) {
+ MD5_Update(&c, data, (unsigned long)len);
+ ret = rgwstore->put_obj_data(s->user.user_id, s->bucket_str, s->object_str, data, ofs, len, NULL);
+ free(data);
+ if (ret < 0)
+ goto done;
+ ofs += len;
+ }
+ } while ( len > 0);
+
MD5_Final(m, &c);
buf_to_hex(m, MD5_DIGEST_LENGTH, calc_md5);
get_request_metadata(s, attrs);
- ret = rgwstore->put_obj(s->user.user_id, s->bucket_str, s->object_str, data, len, NULL, attrs);
+ ret = rgwstore->put_obj_meta(s->user.user_id, s->bucket_str, s->object_str, NULL, attrs);
}
done:
- free(data);
send_response();
}
protected:
int ret;
size_t len;
+ off_t ofs;
char *data;
struct rgw_err err;
char *supplied_md5_b64;
RGWOp::init(s);
ret = 0;
len = 0;
+ ofs = 0;
data = NULL;
supplied_md5_b64 = NULL;
}
void execute();
virtual int get_params() = 0;
+ virtual int get_data() = 0;
virtual void send_response() = 0;
};
else
len = end - ofs + 1;
+ if (len > RGW_MAX_CHUNK_SIZE)
+ len = RGW_MAX_CHUNK_SIZE;
+
cout << "rados->read ofs=" << ofs << " len=" << len << std::endl;
int r = rados->read(state->pool, oid, ofs, bl, len);
cout << "rados->read r=" << r << std::endl;
memcpy(*data, bl.c_str(), bl.length());
}
- if (r < 0 || !len || (ofs + len - 1 == end)) {
+ if (r < 0 || !len || ((off_t)(ofs + len - 1) == end)) {
rados->close_pool(state->pool);
delete state;
}
int RGWPutObj_REST::get_params()
{
- size_t cl = atoll(s->length);
+ supplied_md5_b64 = FCGX_GetParam("HTTP_CONTENT_MD5", s->fcgx->envp);
+
+ return 0;
+}
+
+int RGWPutObj_REST::get_data()
+{
+ size_t cl = atoll(s->length) - ofs;
+ if (cl > RGW_MAX_CHUNK_SIZE)
+ cl = RGW_MAX_CHUNK_SIZE;
+ len = 0;
if (cl) {
data = (char *)malloc(cl);
if (!data)
~RGWPutObj_REST() {}
int get_params();
+ int get_data();
void send_response();
};