Skip to content

Instantly share code, notes, and snippets.

@mishazawa
Created February 27, 2024 13:53
Show Gist options
  • Select an option

  • Save mishazawa/0b48409afdb10aeda56ece4d1a265042 to your computer and use it in GitHub Desktop.

Select an option

Save mishazawa/0b48409afdb10aeda56ece4d1a265042 to your computer and use it in GitHub Desktop.
# Usage:
# python3 convert_base64_to_fbx.py ./out.fbx ./base64_file
import io
import base64
import sys
BASE_CONTENT = sys.argv[2]
OUT_FILE_PATH = sys.argv[1]
if __name__ == "__main__":
with open(BASE_CONTENT, 'r') as in_file:
str_content = in_file.read()
with open(OUT_FILE_PATH, 'wb') as out_file:
data = io.BytesIO(base64.decodebytes(str_content.encode('ascii')))
out_file.write(data.read())
# Usage:
# python3 convert_fbx_to_base64.py ./in.fbx > ./base64_file
import sys, base64
def main():
with open(sys.argv[1], 'rb') as f:
content = (base64.b64encode(f.read())).decode('ascii')
print(content)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment