Skip to content

Open should support io.ReaderAt so passing *os.File doesn't call ioutil.ReadAll #3

@wizardishungry

Description

@wizardishungry

Ran into a memory exhaustion issue with this when processing large documents with embedded videos.
As a workaround, I call NewPackage directly:

type OOXmlDoc struct {
	*ooxml.PackageInfo
}

stat, err := file.Stat()
if err != nil {
	return fmt.Errorf("file.Stat: %w", err)
}

size := stat.Size()
zr, err := zip.NewReader(file, size)
if err != nil {
	return fmt.Errorf("zip.NewReader: %w", err)
}

pkg := ooxml.NewPackage(zr)
doc := &OOXmlDoc{pkg}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions