Skip to content
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

Should get_bin_file in PluginBase always decode base64? #25

Open
umesh-timalsina opened this issue Mar 30, 2021 · 1 comment
Open

Should get_bin_file in PluginBase always decode base64? #25

umesh-timalsina opened this issue Mar 30, 2021 · 1 comment

Comments

@umesh-timalsina
Copy link

umesh-timalsina commented Mar 30, 2021

While the get_bin_file shown below decodes a binary treating it as a base64 encoded string, it might not always be the case. Specifically, if the artifiact is loaded from elsewhere (like type: asset) from the plugin metadata? Or any artifact from the BlobClient.

def get_bin_file(self, metadata_hash, sub_path = None):
"""
Retrieves the file from blob storage.
:param metadata_hash: the "id" of the file to retrieve.
:type metadata_hash: str
:param sub_path: the path of the file to retrieve if it is inside an artifact/complex blob.
:type sub_path: str
:returns: The file content.
:rtype: bytes
:raises JSError: The result of the execution.
"""
content_as_string = self._send({'name': 'getBinFile', 'args': [metadata_hash, sub_path]})
return base64.b64decode(content_as_string.encode('UTF-8'))

@umesh-timalsina umesh-timalsina changed the title Should get_bin_file in PluginBase always decode base64?w Should get_bin_file in PluginBase always decode base64? Mar 30, 2021
@kecso
Copy link
Member

kecso commented Apr 1, 2021

I believe it is a constraint that most people can live with, and it would make the process of dealing with binaries a lot more complex on the server side. It is the user who knows how their artifact if binary are coded. Therefore, they can convert it to the widely accepted base64 before storing it to the blob.
I do not see how this could be a real limit factor, but I do see that it would be extremely hard/brittle to allow multiple encodings on the blob. On the other side of things, you cannot provide the binary for the plugin with multiple encodings either as they might not be prepared for that. So in the end it would make the plugins life harder as well. Those plugins that are connected to other functions that might dealt with other encodings will know exactly if they need to convert back the retrieved data...

So unless there is a use-case where it is impossible to change the encoding of some binary content before uploading it to the blob, I do not see why the blob should have this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants