# Simplest (and cheapest) way to upload/store/retrieve images

**URL:** <https://discourse.elm-lang.org/t/simplest-and-cheapest-way-to-upload-store-retrieve-images/10000>\
**Category:** Learn\
**Created:** [October 1, 2024, 3:29pm UTC](https://discourse.elm-lang.org/t/simplest-and-cheapest-way-to-upload-store-retrieve-images/10000 "2024-10-01T15:29:09Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![wolfadex](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/wolfadex/32/2461_2.png) [@wolfadex](https://discourse.elm-lang.org/u/wolfadex)\
**Post date:** [October 3, 2024, 6:51pm UTC](https://discourse.elm-lang.org/t/simplest-and-cheapest-way-to-upload-store-retrieve-images/10000/8 "2024-10-03T18:51:19Z")

</div>

> [@badlydrawnrob](#):
>
> It’s probably a better idea to make sure there’s no naming conflicts with `elm/...` packages. For now I’m using `File_.SomeModule`.

You should be fine with `File.SomeModule`. If anything I’d give a more accurate name instead of `File`. E.g. your modules seem to deal with images specifically so a more helpful name might be `File.Image` or `ImageFile` or even `Image`.

I also wouldn’t worry specifically about the `elm/*` packages. It’s more of a general issue, like if you used [elm-ui 1.1.8](https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/) then you wouldn’t be able to name any of your local modules `Element`. I’d focus more on giving your modules names that make sense when you’re looking at the name along.

> [@badlydrawnrob](#):
>
> **I didn’t think to do that.** Do you mean `Just url` → `onClick (SendToServer url)`?

Exactly!

> [@badlydrawnrob](#):
>
> In the [`csv` example](https://package.elm-lang.org/packages/elm/file/latest/) he’s using a `Task` to convert to a string …

Which makes sense because a csv file is a specialized text file. If you open it in your text editor it’s still legible.

> [@badlydrawnrob](#):
>
> - At which point (in the update) you wouldn’t be able to grab the `name` anymore.
> - Is there a better way to do this?

```elm
ImageSelected file ->
      ( model
      , Task.perform (ImageLoaded (File.name file)) (File.toString file)
      )

ImageLoaded filename content ->
      ( { model
            | image = Just content
            , imageName = filename
        }
      , Cmd.none
      )

```

can be converted to

```elm
ImageSelected file ->
      ( { model | imageName = File.name file }
      , Task.perform ImageLoaded (File.toString file)
      )

ImageLoaded content ->
      ( { model
            | image = Just content
        }
      , Cmd.none
      )

```

there’s no need to pass the name through the message+update loop again (as best I can tell).

* * *

A small stylistic opinion. I’d merge all of your `File_.*` modules into a single module. A module should generally be a container of sorts around a specific type. I’d also recommend [Components | Elm Land](https://elm.land/concepts/components.html) for a very solid guide about how to model your component like modules.

---

_[View the full topic](https://discourse.elm-lang.org/t/simplest-and-cheapest-way-to-upload-store-retrieve-images/10000)._
