-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【RFC】add metadata to FileBox #3
Comments
It's a reasonable request, and it should be considering all the possible file box types. I'll think about it and reply to you later. Before we have a |
Do you have any idea about how the new If you have any, a PR is welcome to demonstrate what you need, and we can go on discussing about it based on your PR. |
Actually for my use case, I just need a key-value pair in side the const f: FileBox = magicMethodGetMeOneFileBoxObject()
f.metadata.voiceLength = 9129392 So it could just be an |
You should get your |
That was blazing fast for adding features :)I had some additional thoughts about this feature, I came up with this idea when I was laying on bed last night, so sorry for late statement of this idea. It would be better to have I think we can pass an const meta = { zelda: 'breath of the wind' }
const f = FileBox.fromBase64(data, meta)
// When try to modify the data
f.metadata.zelda = 'game over'
// Expect an error thrown out Probably we can use deep-froze on the What do you think about this? |
It's fast because this feature makes sense for the use cases. I feel it's enough to use just Object.freeze() instead of doing a recursively because it will be too expensive. Should be ready for use with the code from the latest master branch. (v0.8.24 or above) |
Could you please help me to add a documentation entry in README for the new |
PRed: #4 Please revise the PR if you see anything improper, I am closing this issue since the feature is implemented. |
Hi @zixia ,
I am working on sending voice message to other people in wechaty, and I realized that the voice length has to be passed when we send out voice message. And this information is pretty hard to be retrieved from the data, so I think it makes sense to add a
metadata
field in FileBox so for voice message that I received, I can persist the voice length in themetadata
, then when use theFileBox
voice file to send message, I can retrieve it from theFileBox
object itself.Currently I observed that there is a
mimeType
field inFileBox
, and it is used only for url relatedFileBox
object, I can possibly save the voice length inside that, or put it into the file name, but that is all work around, not elegant solutions. So I think themetadata
field will be the final solution to my problem.Please let me know your thought.
The text was updated successfully, but these errors were encountered: