0

I'm not too sure how to word this one, but I've got a job called uploadFile, which uses CloudConvert to convert an uploaded file (e.g PDF) to a JPG.

Used in isolation, it all works great. I can upload a file, it'll be saved to S3, then CloudConvert gets the S3 file, converts it and uploads that too. Perfect.

When it's being used by more than one person at a time, the files get mixed up. The filenames are correct (so the variables themselves must be correct), but the actual image processed is someone else's somehow.

$originalFileName = str_replace('.'.$this->extension, '', $this->actualFileName);
$tempName = $originalFileName.'_'.time().'.jpg';
$fileName = $originalFileName.'_'.time();

Storage::disk('s3')->put($folder.$fileName, $file, 'public');

$fileUrl = Storage::disk('s3')->url($fileName);

CloudConvert::file($fileUrl)
    ->withOptions([
        'quality' => 80,
        'resize' => '400x400',
    ])->to(CloudConvert::S3($tempName));

In the above, the file in Storage->put() is correct, as is $tempName and $fileName. Somehow, the file it's converting is wrong, so the output Jpeg is from someone else's upload.

Does anyone have any idea of what I can try? I'm not even sure where to begin debugging that.

MitchEff
  • 1,417
  • 14
  • 29

2 Answers2

0

Simple Exchange time()

$mark = microtime().rand(10,100);
$tempName = $originalFileName.'_'.$mark.'.jpg';
$fileName = $originalFileName.'_'.$mark;
FAEWZX
  • 991
  • 7
  • 10
  • I'm not sure that'll help, I'm afraid. The filenames themselves are completely different to one another, so it isn't an issue of conflicting filenames. – MitchEff Feb 13 '19 at 06:32
0

Eugh, okay I finally worked it out. CloudConvert needed to be reinstantiated. See thread here, if anyone ever encounters this again.

MitchEff
  • 1,417
  • 14
  • 29