# Read .mat file from base64

**URL:** <https://discourse.julialang.org/t/read-mat-file-from-base64/58217>\
**Category:** General Usage\
**Tags:** base64\
**Created:** [March 30, 2021, 11:41am UTC](https://discourse.julialang.org/t/read-mat-file-from-base64/58217 "2021-03-30T11:41:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iulian.Cioarca](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iulian.cioarca/32/30166_2.png) [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Post date:** [March 30, 2021, 11:41am UTC](https://discourse.julialang.org/t/read-mat-file-from-base64/58217/1 "2021-03-30T11:41:58Z")

</div>

Suppose I have the following based64 encoded .mat file:

```julia
using MAT
using Base64

mat_enc = open(base64encode, "01.mat")
mat_dec = base64decode(mat_enc)
open("my_01.mat", "w") do f
	write(f, mat_dec)
end
data = matread("mymat.mat")

```

Is it possible to read the contents of the decoded base64 directly, without writing the .mat file to disk?

---

<div class="post-metadata">

**Author:** ![chris-b1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chris-b1/32/14165_2.png) [@chris-b1](https://discourse.julialang.org/u/chris-b1)\
**Post date:** [March 30, 2021, 1:35pm UTC](https://discourse.julialang.org/t/read-mat-file-from-base64/58217/2 "2021-03-30T13:35:36Z")

</div>

The typical solution to this would be to wrap `mat_dec` in an [`IOBuffer`](https://docs.julialang.org/en/v1/base/io-network/#Base.IOBuffer).

But it looks like `MAT` only takes filenames as inputs to .`matread`, `matopen` - maybe could be enhanced to take an `<: IO`
