// OpenZipWriter creates a new bundle in the given store using the given id and // bundle number. It returns a zip writer which is then saved into the store. func OpenZipWriter(s store.Store, id string, n int) (*Zipwriter, error) { f, err := s.Create(sugar(id, n)) if err != nil { return nil, err } return &Zipwriter{ f: f, Writer: bagit.NewWriter(f, strings.TrimSuffix(id, ".zip")), }, nil }
// OpenBundle opens the provided key in the given store, and wraps it in a // bagit reader. func OpenBundle(s store.Store, key string) (*BagreaderCloser, error) { stream, size, err := s.Open(key) if err != nil { return nil, err } var result *BagreaderCloser r, err := bagit.NewReader(stream, size) if err == nil { result = &BagreaderCloser{ Reader: r, f: stream, } } else { stream.Close() } return result, err }