Skip to content

Not able to call different methods on the client for the same *os.File #29

@YashMeh

Description

@YashMeh

Hi,
Thanks for the awesome package.
I am trying to run the following code but it only works for the first function call whether it be .Parse,.Detect or .Meta . I am wondering whether it is the limitation of the package or of golang GC itself and how could I solve it.

func ReadData(s *indexService) {
	//Open the file
	f, err := os.Open(fileDir)
	if err != nil {
		fmt.Println("[ERROR] Opening file")
	}
	defer f.Close()
	c := context.Background()
	
	//First function call works fine
	docBody, err := s.TClient.Parse(c, f)
	if err != nil {
		fmt.Println("[ERROR] Reading body")
	}
	//Returns file already closed error
	docContent, err := s.TClient.Detect(c, f)
	if err != nil {
		fmt.Println(err)
		fmt.Println("[ERROR] Reading MIMETYPE")
	}
	//Returns file already closed error
	docMeta, err := s.TClient.Meta(c, f)
	if err != nil {
		fmt.Println("[ERROR] Reading Meta-data")
	}
	
	defer func() {
		fmt.Printf("Tika Processed: %s \n", fileName)
	}()
	
}

indexService looks like this -

type indexService struct {
	TClient *tika.Client
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions