Reading files in binary format

• Aug 1, 2019 - 07:08

Hello All!
I'm trying to write a plugin that would allow sending files in pdf, midi formats to our webservice for further publication.
The following scenario is implemented:
- the user creates a composition (score),
- runs the plugin,
- the plugin exports the score to pdf and midi files on local disk,
- read and sends them to our web service.

I found the following problem: pdf files need to be read in binary format, FileIO component decodes non-ASCII characters when reading. I tried to read binary files using XMLHttpRequest, but in this case there is a distortion.

Please advise how I can solve this problem?

I use MuseScore version (64-bit): for Windows

Thank you.


The Qt File interface is only exposed through MuseScores FileIO object and handles text streams only.

But since you're using XMLHttpRequest anyway, you could use that instead. In QML there is no same-origin policy, meaning it can be used to read files from your local disk.

See attached example where the following file is being read in:
As you'll notice from the logging, the data doesn't stop after a 0 byte when using the ArrayBuffer response type.

Don't forget to remove the .qml extention from the readme.bin file; I've added it to be able to upload and attach it to this post.

Attachment Size
readbinary.qml 1.29 KB
readme.bin_.qml 23 bytes

Do you still have an unanswered question? Please log in first to post your question.