I'm having trouble getting the URI from a specific file, for example .mp4 / .ogg / etc .. The thing is, I need to do this in python, where the web server is running.
Initially, I do the following:
def __parse64(self, path_file):
string_file = open(path_file, 'r').readlines()
new_string_file = ''
for line in string_file:
striped_line = line.strip()
separated_lines = striped_line.split('\n')
new_line = ''
for l in separated_lines:
new_line += l
new_string_file += new_line
self.encoded_string_file = b64.b64encode(new_string_file)
But this method does not give what I need if you compare the result with the data here.
What I need is a way to implement the readAsDataURL () function from the FileReader class (see link code above) in python.
UPDATE:
The solution given by @SeanVieira returns a valid data field for the URI.
def __parse64(self, path_file):
file_data = open(path_file, 'rb').read(-1)
self.encoded_string_file = b64.b64encode(file_data)
Now, how can I complete the URI with the previous fields? Like that .
For example: data: video / mp4; base64, data p>
Thank!
Nacho source
share