Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Fix relative and absolute filename path handling
Browse files Browse the repository at this point in the history
Issue: #3
  • Loading branch information
aharbis committed Jan 3, 2020
1 parent 68ff38f commit b128e0a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dp_file_uploader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import urllib3
import re
import xml.dom.minidom
import os.path


# Disable warnings, as XML Mgmt often has a self-signed certificate
Expand Down Expand Up @@ -86,7 +87,11 @@ def process_file(filename, directory, url, user, password):
print('Preparing to send file: ' + filename)
with open(filename, 'rb') as lines:
data = lines.read()
xml = build_xml(directory, filename, data)
if os.path.isabs(filename):
target_filename = os.path.basename(filename)
else:
target_filename = os.path.basename(os.path.abspath(filename))
xml = build_xml(directory, target_filename, data)
if VERBOSE:
print('Sending POST request')
r = requests.post(url, auth=(user, password), data=xml, verify=False)
Expand Down

0 comments on commit b128e0a

Please sign in to comment.