Skip to content

Commit 1a15eee

Browse files
committed
handle file within with block in parent call to CallServer. Fixes #263
1 parent ccd08cb commit 1a15eee

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tika/tika.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,10 @@ def parse1(option, urlOrPath, serverEndpoint=ServerEndpoint, verbose=Verbose, ti
325325
service = services.get(option, services['all'])
326326
if service == '/tika': responseMimeType = 'text/plain'
327327
headers.update({'Accept': responseMimeType, 'Content-Disposition': make_content_disposition_header(path)})
328-
status, response = callServer('put', serverEndpoint, service, open(path, 'rb'),
329-
headers, verbose, tikaServerJar, config_path=config_path, rawResponse=rawResponse, requestOptions=requestOptions)
328+
with open(path, 'rb') as f:
329+
status, response = callServer('put', serverEndpoint, service, f,
330+
headers, verbose, tikaServerJar, config_path=config_path,
331+
rawResponse=rawResponse, requestOptions=requestOptions)
330332

331333
if file_type == 'remote': os.unlink(path)
332334
return (status, response)

0 commit comments

Comments
 (0)