spf13 / afero

A FileSystem Abstraction System for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I unzip a file inside of a afero fs

schuster-rainer opened this issue · comments

Is it possible to unzip an archive that has been written to the afero fs? All my services are using the afero.Fs interface for IO.

I have a Downloader that stores a zip file and now I'm implementing an unzipper that takes an afero.Fs (where the file is stored) and I want to unzip the file inside the afero.Fs. In the zipfs example, an afero.fs is created based on zip.OpenReader. that uses the os package to open the zip file. But I want to open a zipfile within an afero fs. Is there support for it that I don't see? I just don't get it how to do it.

I was too fast opening this ticket.

	fileInfo, err := u.appFS.Stat(source)
	if err != nil {
		return err
	}
	file, err := u.appFS.OpenFile(source, os.O_RDONLY, os.FileMode(0644))
	if err != nil {
		return err
	}

	reader, err := zip.NewReader(file, fileInfo.Size())
	if err != nil {
		return err
	}

@schuster-rainer close this issue?