Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Not using queues with MediaUploader::fromFile() #25

Open
therealspoljo opened this issue Dec 25, 2019 · 1 comment
Open

Not using queues with MediaUploader::fromFile() #25

therealspoljo opened this issue Dec 25, 2019 · 1 comment

Comments

@therealspoljo
Copy link

Currently MediaUploader::fromFile()->upload() doesn't seem to respect queues, or for some reason it doesn't work out of the box.

/**
* Set the file to be uploaded.
*
* @param UploadedFile $file
* @return MediaUploader
*/
public function setFile(UploadedFile $file)
{
$this->file = $file;
$fileName = $file->getClientOriginalName();
$name = pathinfo($fileName, PATHINFO_FILENAME);
$this->setName($name);
$this->setFileName($fileName);
return $this;
}

/**
* Upload the file to the specified disk.
*
* @return mixed
*/
public function upload()
{
$model = config('media.model');
$media = new $model();
$media->name = $this->name;
$media->file_name = $this->fileName;
$media->disk = config('media.disk');
$media->mime_type = $this->file->getMimeType();
$media->size = $this->file->getSize();
$media->forceFill($this->attributes);
$media->save();
$media->filesystem()->putFileAs(
$media->getDirectory(),
$this->file,
$this->fileName
);
return $media->fresh();
}

@Jack97
Copy link
Contributor

Jack97 commented Jan 13, 2020

Hi @therealspoljo

Could you please provide the stack trace of the error you're receiving and a reproduction case? I'll take a look at this one for you.

Many thanks,
Jack

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants