mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-11-05 04:17:52 +00:00
checkpoint: added x-amz-meta capability
git-svn-id: http://s3fs.googlecode.com/svn/trunk@21 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
parent
8cf9564e12
commit
008b87f6d8
@ -167,13 +167,25 @@ get_date() {
|
|||||||
* @param resource e.g., "/pub"
|
* @param resource e.g., "/pub"
|
||||||
*/
|
*/
|
||||||
string
|
string
|
||||||
calc_signature(string method, string content_type, string date, string resource) {
|
calc_signature(string method, string content_type, string date, curl_slist* headers, string resource) {
|
||||||
string Signature;
|
string Signature;
|
||||||
string StringToSign;
|
string StringToSign;
|
||||||
StringToSign += method + "\n";
|
StringToSign += method + "\n";
|
||||||
StringToSign += "\n";
|
StringToSign += "\n"; // md5
|
||||||
StringToSign += content_type + "\n";
|
StringToSign += content_type + "\n";
|
||||||
StringToSign += date + "\n";
|
StringToSign += date + "\n";
|
||||||
|
int count = 0;
|
||||||
|
cout << "calc" << endl;
|
||||||
|
if (headers != 0) {
|
||||||
|
do {
|
||||||
|
cout << headers->data << endl;
|
||||||
|
if (strncmp(headers->data, "x-amz", 5) == 0) {
|
||||||
|
++count;
|
||||||
|
StringToSign += headers->data;
|
||||||
|
StringToSign += 10;
|
||||||
|
}
|
||||||
|
} while ((headers = headers->next) != 0);
|
||||||
|
}
|
||||||
StringToSign += resource;
|
StringToSign += resource;
|
||||||
|
|
||||||
const void* key = AWSSecretAccessKey.data();
|
const void* key = AWSSecretAccessKey.data();
|
||||||
@ -200,6 +212,10 @@ calc_signature(string method, string content_type, string date, string resource)
|
|||||||
|
|
||||||
return Signature;
|
return Signature;
|
||||||
}
|
}
|
||||||
|
string
|
||||||
|
calc_signature(string method, string content_type, string date, string resource) {
|
||||||
|
return calc_signature(method, content_type, date, 0, resource);
|
||||||
|
}
|
||||||
|
|
||||||
// libcurl callback
|
// libcurl callback
|
||||||
static size_t
|
static size_t
|
||||||
@ -277,8 +293,8 @@ s3fs_getattr(const char *path, struct stat *stbuf) {
|
|||||||
if (curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &ContentLength) == 0)
|
if (curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &ContentLength) == 0)
|
||||||
stbuf->st_size = static_cast<__off_t>(ContentLength);
|
stbuf->st_size = static_cast<__off_t>(ContentLength);
|
||||||
|
|
||||||
if (strcmp(ContentType, "application/x-directory") != 0)
|
if (S_ISREG(stbuf->st_mode))
|
||||||
stbuf->st_blocks = stbuf->st_size / 512 + 1;
|
stbuf->st_blocks = stbuf->st_size / S_BLKSIZE + 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -291,6 +307,8 @@ s3fs_readlink(const char *path, char *buf, size_t size) {
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
s3fs_mknod(const char *path, mode_t mode, dev_t rdev) {
|
s3fs_mknod(const char *path, mode_t mode, dev_t rdev) {
|
||||||
|
// see man 2 mknod
|
||||||
|
// If pathname already exists, or is a symbolic link, this call fails with an EEXIST error.
|
||||||
cout << "mknod: path="<< path << endl;
|
cout << "mknod: path="<< path << endl;
|
||||||
|
|
||||||
string resource = urlEncode("/"+bucket + path);
|
string resource = urlEncode("/"+bucket + path);
|
||||||
@ -305,8 +323,9 @@ s3fs_mknod(const char *path, mode_t mode, dev_t rdev) {
|
|||||||
|
|
||||||
auto_curl_slist headers;
|
auto_curl_slist headers;
|
||||||
string date = get_date();
|
string date = get_date();
|
||||||
|
//###headers.append("x-amz-meta-qqq:qqq");
|
||||||
headers.append("Date: "+date);
|
headers.append("Date: "+date);
|
||||||
headers.append("Authorization: AWS "+AWSAccessKeyId+":"+calc_signature("PUT", "application/octet-stream", date, resource));
|
headers.append("Authorization: AWS "+AWSAccessKeyId+":"+calc_signature("PUT", "application/octet-stream", date, headers.get(), resource));
|
||||||
headers.append("Content-Type: application/octet-stream");
|
headers.append("Content-Type: application/octet-stream");
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers.get());
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers.get());
|
||||||
|
|
||||||
@ -403,6 +422,9 @@ s3fs_symlink(const char *from, const char *to) {
|
|||||||
static int
|
static int
|
||||||
s3fs_rename(const char *from, const char *to) {
|
s3fs_rename(const char *from, const char *to) {
|
||||||
cout << "rename:" << " from=" << from << " to=" << to << endl;
|
cout << "rename:" << " from=" << from << " to=" << to << endl;
|
||||||
|
// get file handle
|
||||||
|
// upload as new s3 object
|
||||||
|
// delete old s3 object
|
||||||
return -EXDEV;
|
return -EXDEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,7 +680,7 @@ s3fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset,
|
|||||||
strptime(LastModified.c_str(), "%Y-%m-%dT%H:%M:%SZ", &gmt);
|
strptime(LastModified.c_str(), "%Y-%m-%dT%H:%M:%SZ", &gmt);
|
||||||
st.st_mtime = timegm(&gmt);
|
st.st_mtime = timegm(&gmt);
|
||||||
// blocks
|
// blocks
|
||||||
st.st_blocks = st.st_size / 512 + 1;
|
st.st_blocks = st.st_size / S_BLKSIZE + 1;
|
||||||
// if size is 0 then we don't know whether its a file or a directory...
|
// if size is 0 then we don't know whether its a file or a directory...
|
||||||
// defer to getattr() to determine whether its a file or a directory from Content-Type
|
// defer to getattr() to determine whether its a file or a directory from Content-Type
|
||||||
if (st.st_size > 0) {
|
if (st.st_size > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user