diff --git a/resources/file_resource.inc b/resources/file_resource.inc
index af2c967..a345cfc 100644
--- a/resources/file_resource.inc
+++ b/resources/file_resource.inc
@@ -178,8 +178,15 @@ function _file_resource_create($file) {
     return services_error(t("Could not write file to destination"), 500);
   }
 
-  // Required to be able to reference this file.
-  file_usage_add($file_saved, 'services', 'files', $file_saved->fid);
+  if (isset($file['status']) && $file['status'] == 0) {
+    // Save as temporary file.
+    $file_saved->status = 0;
+    file_save($file_saved);
+  }
+  else {
+    // Required to be able to reference this file.
+    file_usage_add($file_saved, 'services', 'files', $file_saved->fid);
+  }
 
   return array(
     'fid' => $file_saved->fid,
diff --git a/tests/functional/ServicesResourceFileTests.test b/tests/functional/ServicesResourceFileTests.test
index f45c1dc..848426f 100644
--- a/tests/functional/ServicesResourceFileTests.test
+++ b/tests/functional/ServicesResourceFileTests.test
@@ -34,10 +34,11 @@ class ServicesResourceFileTests extends ServicesWebTestCase {
       'save file information',
       'administer services',
       'administer site configuration',
+      'bypass node access',
     ));
     $this->drupalLogin($this->privileged_user);
     // Get a test file.
-    $this->testfiles = $this->drupalGetTestFiles('text');
+    $this->testfiles = $this->drupalGetTestFiles('image');
     $this->testfile = current($this->testfiles);
   }
 
@@ -188,4 +189,73 @@ class ServicesResourceFileTests extends ServicesWebTestCase {
     $this->assertTrue(empty($file_load), t('File deleted.'), 'FileResource: Delete');
   }
 
+  /**
+   * Attach file to the node.
+   */
+  public function testCreateNodeWithFile() {
+    $filepath = file_default_scheme() . '://' . rand() . '/' . rand() . '/' . $this->testfile->filename;
+
+    // Create file that managed by services.
+    $file = array(
+      'filesize' => filesize($this->testfile->uri),
+      'filename' => $this->testfile->filename,
+      'filepath' => $filepath,
+      'file' => base64_encode(file_get_contents($this->testfile->uri)),
+      'uid' => $this->privileged_user->uid,
+    );
+
+    // Create file with call.
+    $result = $this->servicesPost($this->endpoint->path . '/file', $file);
+
+    $fid = $result['body']['fid'];
+    $file_load = file_load($fid);
+
+    // Try to delete the file and ensure that it is not possible.
+    $file_delete_result = file_delete($file_load);
+    $this->assertTrue($file_delete_result !== TRUE, t('It is not possible to delete file managed by services using file_delete().'));
+
+
+    // Create file that is not managed by services.
+    $file = array(
+      'filesize' => filesize($this->testfile->uri),
+      'filename' => $this->testfile->filename,
+      'filepath' => $filepath,
+      'file' => base64_encode(file_get_contents($this->testfile->uri)),
+      'uid' => $this->privileged_user->uid,
+      'status' => 0,
+    );
+
+    // Create file with call.
+    $result = $this->servicesPost($this->endpoint->path . '/file', $file);
+
+    $fid = $result['body']['fid'];
+    $file_load = file_load($fid);
+
+    // Create a node with this file attached.
+    $node = array(
+      'title' => $this->randomString(),
+      'body' => array(LANGUAGE_NONE => array(array('value' => $this->randomString()))),
+      'type' => 'article',
+      'name' => $this->privileged_user->name,
+      'language' => LANGUAGE_NONE,
+      'field_image' => array(LANGUAGE_NONE => array(array('fid' => $fid, 'display' => '1'))),
+    );
+    $response_array = $this->servicesPost($this->endpoint->path . '/node', $node);
+    $nid = $response_array['body']['nid'];
+
+    $node_load = node_load($nid, NULL, TRUE);
+
+    $this->assertEqual($fid, $node_load->field_image[LANGUAGE_NONE][0]['fid'], t('File added to the node successfully.'));
+
+    // Now file should be managed by node. Lets try to delete it and ensure
+    // that it is not possible.
+    $file_delete_result = file_delete($file_load);
+    $this->assertTrue($file_delete_result !== TRUE, t('It is not possible to delete file managed by node using file_delete().'));
+
+    // Delete the node and assert that file can be deleted.
+    node_delete($nid);
+
+    $file_delete_result = file_delete($file_load);
+    $this->assertTrue($file_delete_result === TRUE, t('File can be deleted after node has been removed.'));
+  }
 }
