# \#file

**URL:** https://forum.elixirforum.com/tag/file/453.md

[Latest](https://forum.elixirforum.com/latest.md) · [Categories](https://forum.elixirforum.com/categories.md) · [Tags](https://forum.elixirforum.com/tags.md)

---

## [File.open w/permissions](https://forum.elixirforum.com/t/file-open-w-permissions/44757)

<div class="topic-metadata">

**Author:** [@rlipscombe](https://forum.elixirforum.com/u/rlipscombe)\
**Replies:** 2\
**Last updated:** [November 4, 2026, 5:34pm UTC](https://forum.elixirforum.com/t/file-open-w-permissions/44757 "2026-11-04T17:34:31Z")

</div>

I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. Is there any way to specify file permissions at the same time as creating the file…

---

## [Get proper file creation (birth) time on Linux](https://forum.elixirforum.com/t/get-proper-file-creation-birth-time-on-linux/72395)

<div class="topic-metadata">

**Author:** [@spicychickensauce](https://forum.elixirforum.com/u/spicychickensauce)\
**Replies:** 8\
**Last updated:** [September 14, 2025, 3:28pm UTC](https://forum.elixirforum.com/t/get-proper-file-creation-birth-time-on-linux/72395 "2025-09-14T15:28:55Z")

</div>

File.stat gives me a pretty useless value for ctime. As documented it is “the last time the file or the inode was changed“. Using stat via bash gives me a correct creation time via the Birth field. I understand why tha…

---

## [Weird behaviour of File.open](https://forum.elixirforum.com/t/weird-behaviour-of-file-open/72477)

<div class="topic-metadata">

**Author:** [@ademenev](https://forum.elixirforum.com/u/ademenev)\
**Replies:** 3\
**Last updated:** [September 10, 2025, 11:47pm UTC](https://forum.elixirforum.com/t/weird-behaviour-of-file-open/72477 "2025-09-10T23:47:22Z")

</div>

Can’t figure out what’s happening here Erlang/OTP 27 \[erts-15.2\] \[source\] \[64-bit\] \[smp:10:10\] \[ds:10:10:10\] \[async-threads:1\] \[jit\] Elixir 1.18.0 (compiled with Erlang/OTP 27) iex(1)\> File.open("/tmp/x.png", \[:read…

---

## [There is some advantage to use \`File.open\` instead \`File.write\`?](https://forum.elixirforum.com/t/there-is-some-advantage-to-use-file-open-instead-file-write/71578)

<div class="topic-metadata">

**Author:** [@almir-neto](https://forum.elixirforum.com/u/almir-neto)\
**Replies:** 6\
**Last updated:** [July 6, 2025, 6:50pm UTC](https://forum.elixirforum.com/t/there-is-some-advantage-to-use-file-open-instead-file-write/71578 "2025-07-06T18:50:02Z")

</div>

I know that File.write performs two operations: it opens the file and then writes to it. However, considering that File.open followed by IO.write avoids one operation for each iteration, I want to know: when I’m building…

---

## [Syslog server performance issue with appending log](https://forum.elixirforum.com/t/syslog-server-performance-issue-with-appending-log/69003)

<div class="topic-metadata">

**Author:** [@awksedgreep1](https://forum.elixirforum.com/u/awksedgreep1)\
**Replies:** 4\
**Last updated:** [January 26, 2025, 3:20pm UTC](https://forum.elixirforum.com/t/syslog-server-performance-issue-with-appending-log/69003 "2025-01-26T15:20:05Z")

</div>

Apologies if this has been asked before, but I couldn’t find a reference to this issue on the forum. I’m writing a syslog server for a DOCSIS stack I’m working on and would love to have an efficient way to append a log.…

---

## [LSP throwing strange warnings when using File.write](https://forum.elixirforum.com/t/lsp-throwing-strange-warnings-when-using-file-write/68688)

<div class="topic-metadata">

**Author:** [@donnieparka](https://forum.elixirforum.com/u/donnieparka)\
**Replies:** 3\
**Last updated:** [January 13, 2025, 3:56pm UTC](https://forum.elixirforum.com/t/lsp-throwing-strange-warnings-when-using-file-write/68688 "2025-01-13T15:56:34Z")

</div>

def write\_boilerplate(project\_name) do file\_name = project\_name \<\> ".ex" file\_path = Path.join(\[project\_name, file\_name\]) boilerplate = "defmodule #{project\_name} do\\nend" File.write(file\_path, boilerplat…

---

## [Read compressed files as string and not bitstring](https://forum.elixirforum.com/t/read-compressed-files-as-string-and-not-bitstring/65122)

<div class="topic-metadata">

**Author:** [@pelopo](https://forum.elixirforum.com/u/pelopo)\
**Replies:** 6\
**Last updated:** [July 25, 2024, 2:17pm UTC](https://forum.elixirforum.com/t/read-compressed-files-as-string-and-not-bitstring/65122 "2024-07-25T14:17:08Z")

</div>

Hi, I’m reading a file compressed originally with LZMA and ext .txt.xz. I can read it with stream ok, but the output is a bitstring and not a string. How can I convert it to string. The search didn’t give me any meaningf…

---

## [Depot - Filesystem Abstraction](https://forum.elixirforum.com/t/depot-filesystem-abstraction/33930)

<div class="topic-metadata">

**Author:** [@LostKobrakai](https://forum.elixirforum.com/u/LostKobrakai)\
**Replies:** 9\
**Last updated:** [June 6, 2024, 9:00am UTC](https://forum.elixirforum.com/t/depot-filesystem-abstraction/33930 "2024-06-06T09:00:11Z")

</div>

Depot is a filesystem abstraction inspired by the great flysystem PHP package. This allows interacting with many different filesystems (cloud based or not) via a common sensible and in some parts simplified API. Change …

---

## [Hackney returning error regarding keyfile](https://forum.elixirforum.com/t/hackney-returning-error-regarding-keyfile/45502)

<div class="topic-metadata">

**Author:** [@tino415](https://forum.elixirforum.com/u/tino415)\
**Replies:** 4\
**Last updated:** [February 27, 2024, 5:00pm UTC](https://forum.elixirforum.com/t/hackney-returning-error-regarding-keyfile/45502 "2024-02-27T17:00:12Z")

</div>

Hello, I’m getting weird error regarding key file settings when doing request using hackney, it is like this {:error, {:options, {:keyfile, '/cert/key\_rsa.pem', \[\]}}}, I know that when keyfile is not accesible, I get s…

---

## [Can I stream receive from the network?](https://forum.elixirforum.com/t/can-i-stream-receive-from-the-network/16955)

<div class="topic-metadata">

**Author:** [@dimitarvp](https://forum.elixirforum.com/u/dimitarvp)\
**Replies:** 21\
**Last updated:** [December 23, 2023, 4:10pm UTC](https://forum.elixirforum.com/t/can-i-stream-receive-from-the-network/16955 "2023-12-23T16:10:32Z")

</div>

Hey everyone, If I want to stream data from a file, it’s mega easy: File.stream!("/path/to/file") |\> Stream.map(...) |\> Stream.filter(...) |\> ...consume the processed data here... |\> Stream.run Is there a way to do th…

---

## [Streams for processing a tree of folder and file paths?](https://forum.elixirforum.com/t/streams-for-processing-a-tree-of-folder-and-file-paths/60414)

<div class="topic-metadata">

**Author:** [@polypush135](https://forum.elixirforum.com/u/polypush135)\
**Replies:** 6\
**Last updated:** [December 18, 2023, 6:19pm UTC](https://forum.elixirforum.com/t/streams-for-processing-a-tree-of-folder-and-file-paths/60414 "2023-12-18T18:19:48Z")

</div>

I’m looking to learn the File module and was trying to think of a pet project for doing so. I have a huge dir full of mp3 files that I want to organize. Given the nature of music Artist → Album → Track. I figured I w…

---

## [What's the best way to chunk a stream by an arbitrary non-newline character?](https://forum.elixirforum.com/t/whats-the-best-way-to-chunk-a-stream-by-an-arbitrary-non-newline-character/44231)

<div class="topic-metadata">

**Author:** [@j4p3](https://forum.elixirforum.com/u/j4p3)\
**Replies:** 5\
**Last updated:** [September 26, 2023, 2:19am UTC](https://forum.elixirforum.com/t/whats-the-best-way-to-chunk-a-stream-by-an-arbitrary-non-newline-character/44231 "2023-09-26T02:19:30Z")

</div>

When streaming input from a file of unknown size, formatted as a single line of comma-separated values, what’s the best way to operate on each comma-separated element in that file? Example input file input\_file.txt: "A…

---

## [File Copying Cause Liveview to Reload](https://forum.elixirforum.com/t/file-copying-cause-liveview-to-reload/56038)

<div class="topic-metadata">

**Author:** [@carter](https://forum.elixirforum.com/u/carter)\
**Replies:** 7\
**Last updated:** [May 23, 2023, 4:00am UTC](https://forum.elixirforum.com/t/file-copying-cause-liveview-to-reload/56038 "2023-05-23T04:00:28Z")

</div>

During a drag and drop operation, File.copy(src, dest) in my code would cause Liveview to reload. How can I prevent this?

---

## [How to create a new file if none exists yet](https://forum.elixirforum.com/t/how-to-create-a-new-file-if-none-exists-yet/55300)

<div class="topic-metadata">

**Author:** [@Astarno](https://forum.elixirforum.com/u/Astarno)\
**Replies:** 2\
**Last updated:** [April 15, 2023, 1:52pm UTC](https://forum.elixirforum.com/t/how-to-create-a-new-file-if-none-exists-yet/55300 "2023-04-15T13:52:11Z")

</div>

I’m suprised I couldn’t find the answer to this question anywhere, but how do you go about creating a new (text) file in Elixir if none exists yet? I went through the whole documentation of File but it seems you can onl…

---

## [Reading mtime (stat) to microsecond accuracy](https://forum.elixirforum.com/t/reading-mtime-stat-to-microsecond-accuracy/54727)

<div class="topic-metadata">

**Author:** [@the\_wildgoose](https://forum.elixirforum.com/u/the_wildgoose)\
**Replies:** 9\
**Last updated:** [April 8, 2023, 1:57pm UTC](https://forum.elixirforum.com/t/reading-mtime-stat-to-microsecond-accuracy/54727 "2023-04-08T13:57:17Z")

</div>

I tried using File.state(“some/file”) and discovered that it truncates the timestamps to the nearest second. It seems to be a wrapper for the underlying erlang call: :file.read\_file\_info(‘some/file’, \[{:time, :posix…

---

## [Need help understanding the Erlang file server](https://forum.elixirforum.com/t/need-help-understanding-the-erlang-file-server/53350)

<div class="topic-metadata">

**Author:** [@mruoss](https://forum.elixirforum.com/u/mruoss)\
**Replies:** 4\
**Last updated:** [January 23, 2023, 9:13am UTC](https://forum.elixirforum.com/t/need-help-understanding-the-erlang-file-server/53350 "2023-01-23T09:13:09Z")

</div>

I’m having a hard time understanding the file server concept in Erlang. From the docs I came up with some assumptions, but I’m not sure they actually hold. So I assume that this only makes a difference if you’re running…

---

## [File.exists? on windows](https://forum.elixirforum.com/t/file-exists-on-windows/51903)

<div class="topic-metadata">

**Author:** [@Marcus](https://forum.elixirforum.com/u/Marcus)\
**Replies:** 3\
**Last updated:** [November 20, 2022, 2:55pm UTC](https://forum.elixirforum.com/t/file-exists-on-windows/51903 "2022-11-20T14:55:23Z")

</div>

Hello. I have a test that fails on GitHub under windows. I have no windows running. Could someone with window check: iex(1)\> File.mkdir("bar") :ok iex(2)\> File.touch("baz") :ok iex(3)\> File.exists?("bar/../baz") true ie…

---

## [Receiving unexpected exception with File.cp](https://forum.elixirforum.com/t/receiving-unexpected-exception-with-file-cp/50382)

<div class="topic-metadata">

**Author:** [@jeramyRR](https://forum.elixirforum.com/u/jeramyRR)\
**Replies:** 6\
**Last updated:** [September 20, 2022, 4:52pm UTC](https://forum.elixirforum.com/t/receiving-unexpected-exception-with-file-cp/50382 "2022-09-20T16:52:28Z")

</div>

Hi all, I’m wrapping File.cp in case, but I’m never getting to the {:error, reason} clause even though there is an error. Here’s the code: 76: defp copy\_file(from\_path, to\_path) do 77: case File.exists?(from\_path) d…

---

## [File Module Mutual exclusion?](https://forum.elixirforum.com/t/file-module-mutual-exclusion/49733)

<div class="topic-metadata">

**Author:** [@apoorv-2204](https://forum.elixirforum.com/u/apoorv-2204)\
**Replies:** 7\
**Last updated:** [September 7, 2022, 7:54am UTC](https://forum.elixirforum.com/t/file-module-mutual-exclusion/49733 "2022-09-07T07:54:08Z")

</div>

Is the file module provided by elixir, writes to file in mutual exclusion.?

---

## [Do I need to File.close() after File.stream!()?](https://forum.elixirforum.com/t/do-i-need-to-file-close-after-file-stream/49397)

<div class="topic-metadata">

**Author:** [@1stSolo](https://forum.elixirforum.com/u/1stSolo)\
**Replies:** 2\
**Last updated:** [August 7, 2022, 6:47am UTC](https://forum.elixirforum.com/t/do-i-need-to-file-close-after-file-stream/49397 "2022-08-07T06:47:02Z")

</div>

Do I need to close the file after the end of the stream is reached, if it was a file stream? Also, does the file need to be closed if there was an error reading from the stream? Or does Elixir close the file automatica…

---

## [Creating routes from a file](https://forum.elixirforum.com/t/creating-routes-from-a-file/49276)

<div class="topic-metadata">

**Author:** [@kif](https://forum.elixirforum.com/u/kif)\
**Replies:** 8\
**Last updated:** [August 3, 2022, 4:14pm UTC](https://forum.elixirforum.com/t/creating-routes-from-a-file/49276 "2022-08-03T16:14:44Z")

</div>

I’m trying to migrate a website to Phoenix. I have a JSON file with routes definitions. How can I route traffic base on my file definitions? I fond this post but it only adds more questions.

---

## [Store generated file inside created path](https://forum.elixirforum.com/t/store-generated-file-inside-created-path/48249)

<div class="topic-metadata">

**Author:** [@Hasimbola](https://forum.elixirforum.com/u/Hasimbola)\
**Replies:** 9\
**Last updated:** [June 7, 2022, 12:47pm UTC](https://forum.elixirforum.com/t/store-generated-file-inside-created-path/48249 "2022-06-07T12:47:38Z")

</div>

Hello , I have this code def get\_image do {:ok, query} = Repo.query("SELECT photolink FROM produits") for c \<- query.rows do {:ok, photo} = Enum.fetch(c, 0) File.write("/tmp/#{photo}", photo, \[:binary\]) end e…

---

## [Create and replace mix.exs file](https://forum.elixirforum.com/t/create-and-replace-mix-exs-file/47756)

<div class="topic-metadata">

**Author:** [@shahryarjb](https://forum.elixirforum.com/u/shahryarjb)\
**Replies:** 7\
**Last updated:** [May 16, 2022, 8:21am UTC](https://forum.elixirforum.com/t/create-and-replace-mix-exs-file/47756 "2022-05-16T08:21:24Z")

</div>

Hi my friends, Imaging you have a mix file which you want to change part of it and replace after doing your changes. For example defmodule Dvote.MixProject do use Mix.Project def project do \[ .. \] end de…

---

## [Is there a way to create a tar file in memory in elixir?](https://forum.elixirforum.com/t/is-there-a-way-to-create-a-tar-file-in-memory-in-elixir/47470)

<div class="topic-metadata">

**Author:** [@PabloG6](https://forum.elixirforum.com/u/PabloG6)\
**Replies:** 16\
**Last updated:** [May 3, 2022, 4:45am UTC](https://forum.elixirforum.com/t/is-there-a-way-to-create-a-tar-file-in-memory-in-elixir/47470 "2022-05-03T04:45:22Z")

</div>

Is there a way to create a tar file in memory in elixir?

---

## [Read /dev/input/event\* via IO.binread ?](https://forum.elixirforum.com/t/read-dev-input-event-via-io-binread/47402)

<div class="topic-metadata">

**Author:** [@qloop](https://forum.elixirforum.com/u/qloop)\
**Replies:** 2\
**Last updated:** [April 24, 2022, 10:16pm UTC](https://forum.elixirforum.com/t/read-dev-input-event-via-io-binread/47402 "2022-04-24T22:16:32Z")

</div>

Hi, Is there is any simple way to read binary stream from /dev/input/event file (e.g mouse event) without any extra libs (like input\_event)? Just with loop + File.open and (?) IO.binstream for example. I have tried diff…

---

## [I stuck with this text-file manipulation problem](https://forum.elixirforum.com/t/i-stuck-with-this-text-file-manipulation-problem/41384)

<div class="topic-metadata">

**Author:** [@ambareesha7](https://forum.elixirforum.com/u/ambareesha7)\
**Replies:** 17\
**Last updated:** [March 26, 2022, 8:37am UTC](https://forum.elixirforum.com/t/i-stuck-with-this-text-file-manipulation-problem/41384 "2022-03-26T08:37:25Z")

</div>

i stuck with this problem, i could read the text from text-file and index it but i could not update I’m missing something defmodule ReadText do def read\_text\_file(file\_name) do case File.read(file\_name) do …

---

## [How serving static files to 10K client](https://forum.elixirforum.com/t/how-serving-static-files-to-10k-client/45132)

<div class="topic-metadata">

**Author:** [@Rustixir](https://forum.elixirforum.com/u/Rustixir)\
**Replies:** 12\
**Last updated:** [January 11, 2022, 8:24am UTC](https://forum.elixirforum.com/t/how-serving-static-files-to-10k-client/45132 "2022-01-11T08:24:44Z")

</div>

My static files is png/jpeg and many video ( under 20mb ) Each client download one times I not interested in amazon service (s3) I read ngnix benchmark from itself website . It can handle this load in single machine …

---

## [Difference between :utf8 and :encoding option in File.open](https://forum.elixirforum.com/t/difference-between-utf8-and-encoding-option-in-file-open/45129)

<div class="topic-metadata">

**Author:** [@trisolaran](https://forum.elixirforum.com/u/trisolaran)\
**Replies:** 2\
**Last updated:** [January 10, 2022, 12:04pm UTC](https://forum.elixirforum.com/t/difference-between-utf8-and-encoding-option-in-file-open/45129 "2022-01-10T12:04:22Z")

</div>

Hello! when I open a file: What is the difference between passing :utf8 in the list of modes versus using encoding: :utf8 ? (file — OTP 29.0.2 (kernel 11.0.2)) Is the first form a shorthand for the second one? I t…

---

## [File\_size uplad limit change, task.await timeouts](https://forum.elixirforum.com/t/file-size-uplad-limit-change-task-await-timeouts/21237)

<div class="topic-metadata">

**Author:** [@benonymus](https://forum.elixirforum.com/u/benonymus)\
**Replies:** 14\
**Last updated:** [January 7, 2022, 2:02am UTC](https://forum.elixirforum.com/t/file-size-uplad-limit-change-task-await-timeouts/21237 "2022-01-07T02:02:33Z")

</div>

Hey I am trying to up the file size limit on uploads, I added length to Plug.Parsers, but after that I am getting a new error: (exit) exited in: Task.await(%Task{owner: #PID\<0.743.0\>, pid: #PID\<0.748.0\>, ref: #Reference\<…

---

## [After using vim to modify the file, the :file module seems to lose contact with the file?](https://forum.elixirforum.com/t/after-using-vim-to-modify-the-file-the-file-module-seems-to-lose-contact-with-the-file/41354)

<div class="topic-metadata">

**Author:** [@Hentioe](https://forum.elixirforum.com/u/Hentioe)\
**Replies:** 4\
**Last updated:** [July 30, 2021, 6:37pm UTC](https://forum.elixirforum.com/t/after-using-vim-to-modify-the-file-the-file-module-seems-to-lose-contact-with-the-file/41354 "2021-07-30T18:37:15Z")

</div>

I encountered this phenomenon before. I didn’t study the reason in depth at the time, but avoided it in an inefficient way. Steps to reproduce: Open a iex, open a file through the :file module, and write content to it: …

[Next page](https://forum.elixirforum.com/tag/file/453.md?match_all_tags=true&page=1&tags%5B%5D=file)
