.mp4 / .ogg / etc。などの特定のファイルからURIを取得するのに問題があります。問題は、Webサーバーが実行されているPythonでURIを取得する必要があるということです。
最初は、次のように進めます。
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)
しかし、この方法では、結果をここで示したものと比較すると、必要なものは得られません。
aiに必要なのは、PythonでFileReaderクラス(上記のリンクのコードを参照)から関数readAsDataURL()を実装する方法です。
更新: @SeanVieiraによって提供されたソリューションは、URIの有効なデータフィールドを返します。
def __parse64(self, path_file):
file_data = open(path_file, 'rb').read(-1)
self.encoded_string_file = b64.b64encode(file_data)
前のフィールドでURIを完成させるにはどうすればよいですか?このように。
例:data:video / mp4; base64、data
ありがとう!