Merge branch 'MDL-78002' of https://github.com/stronk7/moodle
This commit is contained in:
@@ -72,16 +72,23 @@ class moodlenet_client {
|
||||
|
||||
$moodleneturl = $this->oauthclient->get_issuer()->get('baseurl');
|
||||
$apiurl = rtrim($moodleneturl, '/') . self::API_CREATE_RESOURCE_URI;
|
||||
$stream = $file->get_psr_stream();
|
||||
|
||||
$requestdata = $this->prepare_file_share_request_data(
|
||||
$file->get_filename(),
|
||||
$file->get_mimetype(),
|
||||
$file->get_psr_stream(),
|
||||
$stream,
|
||||
$resourcename,
|
||||
$resourcedescription,
|
||||
);
|
||||
|
||||
return $this->httpclient->request('POST', $apiurl, $requestdata);
|
||||
try {
|
||||
$response = $this->httpclient->request('POST', $apiurl, $requestdata);
|
||||
} finally {
|
||||
$stream->close(); // Always close the request stream ASAP. Or it will remain open till shutdown/destruct.
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1093,6 +1093,7 @@ class file_system_test extends \advanced_testcase {
|
||||
$this->assertInstanceOf(\Psr\Http\Message\StreamInterface::class, $stream);
|
||||
$this->assertEquals(file_get_contents(__FILE__), $stream->getContents());
|
||||
$this->assertFalse($stream->isWritable());
|
||||
$stream->close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -118,6 +118,7 @@ class stored_file_test extends advanced_testcase {
|
||||
$this->assertInstanceOf(\Psr\Http\Message\StreamInterface::class, $stream);
|
||||
$this->assertEquals(file_get_contents($filepath), $stream->getContents());
|
||||
$this->assertFalse($stream->isWritable());
|
||||
$stream->close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user