kodepett

kodepett

I have an oracle database that stores documents (docx, jpg, pdf, png etc) in binary format(BLOB). I need to read the BLOB and convert it to a file with the appropriate format. How can I read and inspect the blob in Elixir to know the file format and convert it to the appropriate file.

Showing Posts 1 to 10

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Does the database not store information about what kind of file it is? Arbitrary file type identification is quite tricky…

peerreynders

peerreynders

Typically you wouldn’t inspect the BLOB to determine its file type - that information tends to be stored alongside with the binary in the database. This is similar to

  • an OS associating a certain file extension with a particular file format
  • a web response giving a media type in the content-type header.

Determining binary content by inspecting it is usually considered a “forensic” technique.

NobbZ

NobbZ

What do you need the file type for?

Usually you can just write the blob to a temporary location, or stream it out to the client without delay or write to disk.

If though you are on linux and really need to know the MIME-type for whatever reasons, you can write the blob to disk and use file_info package to get the MIME-type. Be aware that this uses the file executable and shells out to your operating system. Returned info might be innacurate but as you only have restricted set of possible filetypes it might be accurate “enough”…

kodepett

kodepett OP

Unfortunately there’s no data available aside the blob.

NobbZ

NobbZ

Not even a filename? I’d slap who ever created that database…

kodepett

kodepett OP

I need to migrate the data to a new system- this system works with the actual file.

kodepett

kodepett OP

I wish I knew the database creator and owner of the app for uploading those documents.

NobbZ

NobbZ

Given these circumstances, I think using file directly or through the afforementioned package should give you as much info as you need.

kodepett

kodepett OP

Thanks, I will give it a try.

dimitarvp

dimitarvp

Yep, you don’t have much hope beyond the file tool which can identify quite a lot of file types for you. Try it.

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
pragdave
How do I tell Hologram not to escape HTML when substituting into templates? {Textile.render(@product.long_description)} escapes the HTM...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Stef-Verniers
Hello I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New
csmr
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley: Mutonex gamedesign was finish...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews