Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8082441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:06:01+00:00 2026-06-05T17:06:01+00:00

I have a Yesod application (but question is more general than this) that allows

  • 0

I have a Yesod application (but question is more general than this) that allows file uploads. I also allow file dowloads. I would like to allow users download multiple files with single link. As per this question: How to download multiple files with one HTTP request? the only solution seems to be creation of file archive with all the files inside.

I want to do it in constant memory in Haskell using libraries from Hackage, without writing to disk or executing external programs.

In particular the following are non-solutions:

  • calling external programs to create an archive: the files may be on disk or in some database on accessible via some remote url. the filesystem may be “read only”. executing external programs may be impossible for security reasons. external programs complicate deployment.

  • creating temporary archive on disk from source files: see “read only” filesystem above. Also quite inefficient: writing to disk is pretty slow actually.

  • creating complete archive in memory and serving it afterwards: the files may be quite large (think CD images) and multiple. The memory needed would be too great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:06:08+00:00Added an answer on June 5, 2026 at 5:06 pm

    It very much depends on which file formats you want to support (.zip, .tar.gz, tar.bz2 are the most common), but you can use the zip-archive library to create .zip archives. These archives are produced as lazy byte-strings, meaning that they will be generated on-the-fly. The only tricky part is to produce a value of type Archive with the correct contents. It might for example look like this:

    import Codec.Archive.Zip
    
    -- ... and in your code:
    let archiveTemplate =
      Archive
      { zComment = ByteString.pack "Downloaded from mysite.com"
      , zSignature = Nothing
      , zEntries = []
      }
    
    let filesIWantToInclude = ["foo.png", "bar.iso"]
    entries <- forM filesIWantToInclude $ readEntry []
    let archive = foldr addEntryToArchive archiveTemplate entries
    
    let byteString = fromArchive archive
    -- Now you can send the byteString over the network, or something.
    

    If you don’t have files on your file system that you want to compress, but instead files in a database or something, you can manually build values of type Entry with the correct fields filled in. You only need a lazy ByteString representing the data you want to compress, nothing more; then you can use the toEntry function to generate an entry. It might be worth mentioning that the eRelativePath field in Entry is the relative path of the file inside of the .zip archive, not the actual relative path in the file system.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml file that looks like this <step> <id>3</id> <backid>1</backid> <question>Are you
this is a re-post of my original question that I asked on the yesod
Have data that has this kind of structure. Will be in ascending order by
Have data that has this kind of structure: $input = [ { animal: 'cat',
Have converted devise new session from erb to Haml but doens't work, this is
Have a problem that seems easy on paper but i'm having a big problem
Have some dates in my local Oracle 11g database that are in this format:
Have an app that can use tts to read text messages. It can also
Is there a standard way to not have fields label in a Yesod form?
I am trying to install my Yesod web app on another machine. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.