Binary support in Bulifier
Hello everyone. Today I’d like to share some insights into a longstanding challenge I faced with Bulifier—managing binary files—and the resolution in version 2.3. This update represents a significant milestone, solving all the deletion issues and enabling reliable previewing of binary content such as images, videos, fonts, and PDFs.
Early Challenges
Before version 2.3, previewing binary files in Bulifier was simply not possible. My initial thoughts to store these files directly in the database quickly proved inefficient(I had a long chat with ChatGpt about this). For example, loading an image from the DB required loading the entire file into memory, whereas loading from disk allows Glide to downsize images on the fly—a far more efficient method.
I then experimented with a dedicated folder for storing all project code. This approach, however, had a critical flaw: adding a binary file to that folder would crash Bulifier. Moreover, imposing a rigid folder structure created complications when working with existing projects that had different layouts. To work around this, I adjusted the strategy to load all non-binary files from the project, and during Git synchronization, I deleted the files in the folders where the bullet-point files resided. Although this hack worked to some extent, it failed in scenarios where a regular file was deleted or moved—it would simply not be deleted or be cloned if moved, which was far from ideal.
In a further attempt to resolve these issues, I introduced a Git configuration file that explicitly deleted files from specific folders, I had a complex logic where the system updated the files to find distinct trees. While this method offered some improvements, it quickly became burdensome to manage and maintain, leading to more complexity rather than a streamlined solution.
The Breakthrough in Version 2.3
The breakthrough came with version 2.3. I rethought our approach entirely by leveraging the existing structure we already had—a table for content and a table for files. I decided to create a dedicated binary files folder and store each file using a unique file ID. This strategy effectively decouples the binary content from its file name. As a result, when files are renamed or moved within the database, there’s no longer any need to update or track the binary file names.
During Git synchronization, Bulifier now simply copies the binary files from this dedicated folder. This elegant solution eliminates the need for complicated Git configurations and ensures that binary data remains consistent and unaffected by changes in the database.
The Benefits
With this new approach, Bulifier now supports direct previewing and management of binary files. Here are some of the key benefits:
Efficient Performance:
By storing binary files on disk and using Glide for image handling (along with custom solutions for fonts and videos), we avoid the memory-intensive process of loading entire files from the database.Reliable Previews:
Users can now preview images, videos, and font files directly within Bulifier. PDFs are also supported, opening via the device’s available PDF viewers.Simplified Management:
Decoupling the binary content from file names means that renaming or moving files in the database does not impact the binary files. This approach streamlines Git synchronization and reduces configuration overhead.Enhanced Stability:
The previous hacks—whether deleting files during sync or managing complex Git configs—have been replaced with a robust, scalable solution that integrates seamlessly into Bulifier’s workflow.
Conclusion
The journey to resolve binary file management issues in Bulifier was filled with trial and error. I experimented with several approaches—each teaching valuable lessons—but none provided the reliable, efficient solution we needed until now. With version 2.3, managing binary files is no longer a source of frustration; it’s a well-integrated feature that enhances the overall mobile development experience.
I’m excited about the possibilities this breakthrough opens up and look forward to your feedback as we continue to improve Bulifier. Thank you for reading, and happy coding!
Best regards,
Ilya