Skip to content

Commit 41f2b1c

Browse files
committed
Simplify and ugly temporary fix
1 parent 76fabc4 commit 41f2b1c

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/Factories/Concerns/WithAssets.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ public function asset(string $field, int $width, int $height): string
6464

6565
$image = $this->image($width, $height);
6666

67-
$uploadedFile = $this->uploadedFile($image);
67+
if (!$image) {
68+
ray('no image');
69+
return '';
70+
}
71+
72+
// TODO: Running into "The file "" does not exist" exception.
73+
// The issue seems to be that the image faker library returns an empty string. Maybe because it's returning before the image is downloaded or something like that?
74+
$uploadedFile = new UploadedFile($image, basename($image));
6875

6976
$id = AssetsUploader::field($field->config())->upload($uploadedFile);
7077

@@ -115,18 +122,4 @@ protected function image(int $width, int $height): string
115122

116123
return $this->faker->image($storage->path($dir), $width, $height);
117124
}
118-
119-
protected function uploadedFile(string $path): UploadedFile
120-
{
121-
$filesystem = new Filesystem;
122-
123-
$name = $filesystem->name($path);
124-
$extension = $filesystem->extension($path);
125-
$originalName = "{$name}.{$extension}";
126-
$mimeType = $filesystem->mimeType($path);
127-
$error = null;
128-
$test = true;
129-
130-
return new UploadedFile($path, $originalName, $mimeType, $error, $test);
131-
}
132125
}

0 commit comments

Comments
 (0)