Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content for the "Uploading Files" guide needs to be written #49

Open
2 tasks
mtnygard opened this issue Dec 20, 2016 · 3 comments
Open
2 tasks

Content for the "Uploading Files" guide needs to be written #49

mtnygard opened this issue Dec 20, 2016 · 3 comments

Comments

@mtnygard
Copy link
Contributor

Topics to cover:

  • Single part uploads
  • Multiple file uploads
@bherrmann7
Copy link

bherrmann7 commented Jul 6, 2017

The basic gist is.

  1. Ensure you have a form which is like POST, enctype, input type=file ...

    [:form {:method "POST" :action "/add" :enctype "multipart/form-data"}
    "File"
    [:input {:type "file" :name "file"
    :placeholder "local mp3 file"}]
    [:input {:type "submit" :value "Add File"}]]

  2. Ensure your route has the multipart interceptor aka

    (def routes #{
    ["/add" :post (conj [(io.pedestal.http.ring-middlewares/multipart-params) `add-page])]
    })

  3. pull the data from the request...

    (defn add-page [request]
    (let [file (get (:params request) "file")
    filename (:filename file)
    tempfile (:tempfile file)]
    (io/copy tempfile (io/file "/tmp/destfile"))))

@ddeaguiar
Copy link
Contributor

Prefer a Cookbook recipe.

@Ramblurr
Copy link

Ramblurr commented May 13, 2024

  1. Where is the tempfile created? grepping the pedestal codebase I don't find it
  2. Who is responsible for cleaning up the tempfile? Does pedestal have an analog to ring's temp-file-store which has a handy :expires-in attribute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants