Skip to content

Instantly share code, notes, and snippets.

@ygerasimov
Created January 5, 2011 20:27
Show Gist options
  • Save ygerasimov/766949 to your computer and use it in GitHub Desktop.
Save ygerasimov/766949 to your computer and use it in GitHub Desktop.
function testFileCreate() {
$text_file = current($this->drupalGetTestFiles('text'));
$file = new stdClass();
$realpath = realpath($text_file->filename);
$file->filesize = filesize($realpath);
$file->filepath = 'sites/default/files/' . $text_file->basename;
$fh = fopen($realpath, 'r');
$file_data = fread($fh, $file->filesize);
fclose($fh);
$file->file = base64_encode($file_data);
$response = $this->servicesPost($this->endpoint->path . '/file', array('file' => $file));
}
POST DATA:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment