diff --git a/remote_stream_wrapper.inc b/remote_stream_wrapper.inc
index 0bf560b..6eb12bd 100644
--- a/remote_stream_wrapper.inc
+++ b/remote_stream_wrapper.inc
@@ -69,7 +69,12 @@ class DrupalRemoteStreamWrapper implements DrupalStreamWrapperInterface {
     }
 
     $extension = '';
-    $file_parts = explode('.', basename($uri));
+
+    // Strip out any query arguments that may be part of the basename.
+    $matches = array();
+    preg_match('/^[^?]+/', basename($uri), $matches);
+
+    $file_parts = explode('.', basename($matches[0]));
 
     // Remove the first part: a full filename should not match an extension.
     array_shift($file_parts);
