I’m experiencing an issue setting custom metadata fields on a file using setFileMeta, and I’m not sure whether this behavior is a bug or an intentional constraint.
The uploader I’m using is AWS S3 Multipart. The behavior may or may not occur in other uploaders, although I’m only familiar with AWS S3 and AWS S3 Multipart. I suspect that it may be likelier to occur in AWS S3 Multipart because of the number of function options in that uploader, though; from a skim of the docs of the other uploaders, there appear to be fewer function options.
Here’s the scenario: In createMultipartUpload, I am returning a URL for the file/multipart upload from our server to the client and setting it as a metadata field with setFileMeta in order to minimize the routing logic encoded directly in the client code. (Our application already does something similar for non-multipart uploads.) I was expecting for that URL to be available in the file.meta object in subsequent function calls such as signPart, but it is not present on the file object passed to signPart (and presumably might not be present in other functions, although signPart is the cause of the specific error).
The behavior and its cause, as far as I can determine from debugging in my browser and reading the source code, are as follows:
- The
createMultipartUploadoption I set callsuppy.setFileMetawith my custom metadata field, and the custom metadata field is set in the store for that file. - In
uploadFile,getUploadIdreturns theuploadIdandkeyreturned by my customcreateMultipartUploadfunction, as expected. uploadFilecontinues to calluploadChunkon each chunk, which in turn calls#fetchSignature, which is wrapping my customsignPartfunction.- The
fileargument passed touploadChunk, though, is the same object that was passed touploadFileoriginally because it has never been refetched from the store withgetFile, and therefore does not have the custom metadata that I set increateMultipartUpload. - The file object in the store does have the custom metadata I set, so if I call
getFileinsignPart, I will be able to access the custom metadata. However, it’s easy to imagine a future scenario where this might not be the case if the uploader callssetFileStateat some point with the stale object metadata, although the current code does guard against this, for example, insetS3MultipartState.
So my question is, is this behavior by design, or is it a bug?
More detailed questions if the behavior is by design:
- Is this an appropriate use of
setFileMetaandfile.meta? - If this is an intentional limitation of the AWS S3 Multipart uploader, can that limitation be documented explicitly with guidance to call
getFilein subsequent functions?
Thanks for any guidance you can offer on this subject.