OSS\Http\RequestCore::set_read_file PHP Method

set_read_file() public method

Sets the file to read from while streaming up.
public set_read_file ( string $location )
$location string (Required) The readable location to read from.
    public function set_read_file($location)
    {
        $this->read_file = $location;
        $read_file_handle = fopen($location, 'r');
        return $this->set_read_stream($read_file_handle);
    }

Usage Example

Beispiel #1
0
 public function testGetSignedUrlForPuttingObjectFromFile()
 {
     $file = __FILE__;
     $object = "a.file";
     $timeout = 3600;
     $options = array('Content-Type' => 'txt');
     try {
         $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options);
         $request = new RequestCore($signedUrl);
         $request->set_method('PUT');
         $request->add_header('Content-Type', 'txt');
         $request->set_read_file($file);
         $request->set_read_stream_size(filesize($file));
         $request->send_request();
         $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());
         $this->assertTrue($res->isOK());
     } catch (OssException $e) {
         $this->assertFalse(true);
     }
 }
All Usage Examples Of OSS\Http\RequestCore::set_read_file