function __construct() { $this->auth = null; $this->container = null; $this->temp_name = tempnam(get_tmpdir(), "php-cloudfiles"); $this->object_data = "Some Random text for object data"; }
public function test_filetype_detection_files() { foreach ($this->media_files as $mime) { list($type, $mimetype, $binary_pack) = $mime; # Write Object $object = $this->container->create_object("sample." . $type); # Write temporary files with the proper mime-type $temp = tempnam(get_tmpdir(), "php-cloudfiles-content-type-{$type}"); $temp_fh = fopen($temp, "wb"); fwrite($temp_fh, call_user_func_array("pack", array_merge(array("n*"), (array) $binary_pack))); fclose($temp_fh); $object->load_from_filename($temp); # Get the OBJECT $object = $this->container->get_object("sample." . $type); # Test it $this->assertEquals($object->content_type, $mimetype); # Delete OBJECT $object = $this->container->delete_object("sample." . $type); unlink($temp); } }
protected function __create_big_file($size) { // Check if we have enough free space, this is time two // because we are creating uploading and downloading which // after get compared. if ($size * 2 >= disk_free_space(get_tmpdir())) { print "not enough free space to continue"; exit(1); } $chunk = 8192; $fp = fopen($this->temp_name_write, "wb"); for ($i = 1; $i <= $size;) { $tmp = ""; for ($j = 1; $j < $chunk; $j++) { $tmp .= sprintf("%d", $j * $i); } fwrite($fp, $tmp); $i += strlen($tmp); } fclose($fp); }