tracker issue : CF-3915082

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] ER for: StoreAddMetadata() (no valid/future-proof workaround for its non-existence)

| View in Tracker

Status/Resolution/Reason: To Fix//

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)

Created: 12/27/2014

Components: File Management, VFS-S3

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Win All

Vote Count: 0

StoreAddMetadata() should be added b/c there is no valid future-proof workaround for its non-existence.

Steps to reproduce:
1) run storeAddMetadata("s3://mybucket/file.txt", {foo="bar"})
2) see exception: "Variable STOREADDMETADATA is undefined."
3) run the following:
----
metadata = storeGetMetadata("s3://mybucket/file.txt");
metadata.foo = "bar";
storeSetMetadata("s3://mybucket/file.txt", metadata);
----
4) see exception:
----
Error in Store operation.
rootCause - org.apache.commons.vfs2.FileSystemException: Could not set attribute "Last-Modified" of "s3://mybucket/file.txt".
----
5) run the following (not future-proof):
----
metadata = storeGetMetadata("s3://mybucket/file.txt");
metadata.foo = "bar";
structDelete(metadata, "last_modified");//this is actually "Last-Modified" on the S3 side
structDelete(metadata, "date");//b/c, otherwise, the above FileSystemException will sometimes also be thrown for "Date"
storeSetMetadata("s3://mybucket/file.txt", metadata);
----

Basically, there is no valid workaround for the non-existence of StoreAddMetadata() b/c CF returns metadata field names that do not match-up to S3's field names, so there is no future-proof way to _add_ metadata to an object w/o deleting any/all of the object's other metadata.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3915082

Reason:	BugVerified

External Customer Info:
External Company:  
External Customer Name: itisdesign
External Customer Email:

Attachments:

Comments:

Here is a full repro (2 exceptions are thrown, but 0 exceptions should be thrown): 1) In S3 Management Console, upload file myfile.txt to a bucket (using "mybucket" as an example) 2) In S3 Management Console, add metadata x-amz-meta-foo=foo and x-amz-meta-bar=foo 3) Run the following (to correct only x-amz-meta-bar=foo to x-amz-meta-bar=bar): Application.cfc --------------- component { THIS.name = "ticket_CF-3915082"; THIS.s3.accessKeyID = "access-key-id-here"; THIS.s3.awsSecretKey = "aws-secret-key-here"; } index.cfm --------- <cfscript> myFile = "s3://mybucket/myfile.txt"; metadata = storeGetMetadata(myFile); metadata.bar = "bar"; writeDump(structKeyList(metadata));//returns content_type,request-id,last_modified,Date,ETag,BAR,owner,content_length,id-2 storeSetMetadata(myFile, metadata); </cfscript> 4) See exception (note: "last_modified" exists as "Last-Modified" at the S3 Management Console side): ----------- Error in Store operation. rootCause - org.apache.commons.vfs2.FileSystemException: Could not set attribute "Last-Modified" of "s3://mybucket/myfile.txt". ----------- 5) Run the following: <cfscript> myFile = "s3://mybucket/myfile.txt"; metadata = storeGetMetadata(myFile); structDelete(metadata, "last_modified"); metadata.bar = "bar"; writeDump(structKeyList(metadata));//returns content_type,request-id,Date,ETag,BAR,owner,content_length,id-2 storeSetMetadata(myFile, metadata); </cfscript> 6) See exception (note: metadata key "Date" does not exist at the S3 Management Console side): ----------- Error in Store operation. rootCause - org.apache.commons.vfs2.FileSystemException: Could not set attribute "Date" of "s3://mybucket/myfile.txt". ----------- 7) Run the following: <cfscript> myFile = "s3://mybucket/myfile.txt"; metadata = storeGetMetadata(myFile); structDelete(metadata, "last_modified"); structDelete(metadata, "date"); metadata.bar = "bar"; writeDump(structKeyList(metadata));//returns content_type,request-id,ETag,bar,owner,foo,content_length,id-2 storeSetMetadata(myFile, metadata); </cfscript> 8) See metadata x-amz-meta-bar=bar at the S3 Management Console side (good) Again, 0 exceptions should be thrown.
Comment by External U.
9171 | January 05, 2015 03:24:02 AM GMT
Verified the bug . Attaching test case.
Comment by Suchika S.
9172 | January 06, 2015 01:21:34 AM GMT