mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-07-06 21:11:30 -07:00
uploadFile method of Space class updated and testCanUploadFileWithMimeType method added to SpaceTest.
This commit is contained in:
parent
b7d1a40e70
commit
dc5dc27ff3
2 changed files with 10 additions and 3 deletions
|
@ -302,13 +302,13 @@ class Space
|
||||||
* Upload a file
|
* Upload a file
|
||||||
*
|
*
|
||||||
* @param string $filepath The path to the file, including the filename. Relative and absolute paths are accepted.
|
* @param string $filepath The path to the file, including the filename. Relative and absolute paths are accepted.
|
||||||
* @param string $mimeType The file mime type to pass as ContentType for the file (e.g. 'image/jpeg').
|
|
||||||
* @param string|null $filename The remote filename. If `null`, the local filename will be used.
|
* @param string|null $filename The remote filename. If `null`, the local filename will be used.
|
||||||
|
* @param string|null $mimeType The file mime type to pass as ContentType for the file (e.g. 'image/jpeg').
|
||||||
* @param bool $private True for the file to be private, false to allow public access.
|
* @param bool $private True for the file to be private, false to allow public access.
|
||||||
*
|
*
|
||||||
* @return \SpacesAPI\File
|
* @return \SpacesAPI\File
|
||||||
*/
|
*/
|
||||||
public function uploadFile(string $filepath, string $mimeType, ?string $filename = null, bool $private = true): File
|
public function uploadFile(string $filepath, ?string $filename = null, ?string $mimeType = null, bool $private = true): File
|
||||||
{
|
{
|
||||||
$this->s3->putObject([
|
$this->s3->putObject([
|
||||||
'Bucket' => $this->name,
|
'Bucket' => $this->name,
|
||||||
|
|
|
@ -82,7 +82,14 @@ class SpaceTest extends TestCase
|
||||||
public function testCanUploadFile()
|
public function testCanUploadFile()
|
||||||
{
|
{
|
||||||
$tmpFile = tempnam(sys_get_temp_dir(), 'spaces-test');
|
$tmpFile = tempnam(sys_get_temp_dir(), 'spaces-test');
|
||||||
$file = self::$space->uploadFile($tmpFile, 'text/plain', 'upload-test.txt', false);
|
$file = self::$space->uploadFile($tmpFile, 'upload-test.txt');
|
||||||
|
$this->assertInstanceOf(File::class, $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCanUploadFileWithMimeType()
|
||||||
|
{
|
||||||
|
$tmpFile = tempnam(sys_get_temp_dir(), 'spaces-test');
|
||||||
|
$file = self::$space->uploadFile($tmpFile, 'upload-test.txt', 'text/plain');
|
||||||
$this->assertInstanceOf(File::class, $file);
|
$this->assertInstanceOf(File::class, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue