diff --git a/salt/utils/s3.py b/salt/utils/s3.py
index <HASH>..<HASH> 100644
--- a/salt/utils/s3.py
+++ b/salt/utils/s3.py
@@ -106,6 +106,9 @@ def query(key, keyid, method='GET', params=None, headers=None,
         if local_file:
             payload_hash = salt.utils.get_hash(local_file, form='sha256')
 
+    if path is None:
+        path = ''
+
     if not requesturl:
         requesturl = 'https://{0}/{1}'.format(endpoint, path)
         headers, requesturl = salt.utils.aws.sig4(
@@ -132,13 +135,13 @@ def query(key, keyid, method='GET', params=None, headers=None,
 
     if method == 'PUT':
         if local_file:
-            with salt.utils.fopen(local_file, 'r') as data:
-                result = requests.request(method,
-                                          requesturl,
-                                          headers=headers,
-                                          data=data,
-                                          verify=verify_ssl,
-                                          stream=True)
+            data = salt.utils.fopen(local_file, 'r')
+        result = requests.request(method,
+                                  requesturl,
+                                  headers=headers,
+                                  data=data,
+                                  verify=verify_ssl,
+                                  stream=True)
         response = result.content
     elif method == 'GET' and local_file and not return_bin:
         result = requests.request(method,
Back-port #<I> to <I> (#<I>)

* Fix: local variable result referenced before assignment



* Fix: if 'path' variable is None convert it into an empty string