diff --git a/filefield_paths.module b/filefield_paths.module
index e5e7271..1e32fb8 100644
--- a/filefield_paths.module
+++ b/filefield_paths.module
@@ -430,17 +430,3 @@ function _filefield_paths_get_field_types($reset = FALSE) {
   return $field_types;
 }
 
-/**
- * Check if a uri is considered local or not.
- *
- * @param string $uri
- *   A file uri.
- *
- * @return
- *   TRUE if the uri is using a local stream wrapper, or FALSE otherwise.
- */
-function filefield_paths_uri_is_local($uri) {
-  $scheme = file_uri_scheme($uri);
-  $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_LOCAL);
-  return !empty($wrappers[$scheme]) && empty($wrappers[$scheme]['remote']);
-}
diff --git a/modules/filefield_paths.inc b/modules/filefield_paths.inc
index 55c4cad..2c56650 100644
--- a/modules/filefield_paths.inc
+++ b/modules/filefield_paths.inc
@@ -53,8 +53,12 @@ function filefield_paths_filefield_paths_field_settings($field, $instance) {
 function filefield_paths_filefield_paths_process_file($type, $entity, $field, $instance, $langcode, &$items) {
   if (isset($instance['settings']['filefield_paths'])) {
     $settings = $instance['settings']['filefield_paths'];
+
+    // Check that the destination is writeable.
+    $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE);
     foreach ($items as &$file) {
-      if (filefield_paths_uri_is_local($file['uri']) && ($file['timestamp'] == REQUEST_TIME || $settings['active_updating'])) {
+      $scheme = file_uri_scheme($file['uri']);
+      if (!empty($wrappers[$scheme]) && ($file['timestamp'] == REQUEST_TIME || $settings['active_updating'])) {
         $token_data = array(
           'file' => (object) $file,
           $type => $entity
@@ -71,7 +75,8 @@ function filefield_paths_filefield_paths_process_file($type, $entity, $field, $i
 
         // Process filepath.
         $settings['file_path']['options']['context'] = 'file_path';
-        $file['uri'] = "{$field['settings']['uri_scheme']}://" . ltrim(filefield_paths_process_string($settings['file_path']['value'], $token_data, $settings['file_path']['options']) . "/{$file['filename']}", '/');
+        $path = filefield_paths_process_string($settings['file_path']['value'], $token_data, $settings['file_path']['options']);
+        $file['uri'] = file_stream_wrapper_uri_normalize("{$scheme}://{$path}/{$file['filename']}");
 
         // Finalize file if necessary.
         if ($file !== $old_file) {
