danvergara / morphos

Self-hosted file converter server
MIT License
1.06k stars 44 forks source link

refactor the ConvertTo method to receive and return an object that implements the io reader #43

Closed danvergara closed 6 months ago

danvergara commented 6 months ago

Big Refactor on Converto signature

Description

This PR changes the signature of one of the methods of the File interface. From:

ConvertTo(string, string, []byte) ([]byte, error)

To:

ConvertTo(string, string, io.Reader) (io.Reader, error)

The reasoning behind this changes is that, since we're working with files, we should be working with the abstraction of that, rather than working inner representation of the file. The benefit is that if the file is too large, we could split it into multiple chunks and process a stream of data.

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Tested it locally running the tests and I QA'd this with different kind of files.

Checklist: