dimanche 1 juillet 2018

How does Laravel decide where to put tmp files?

I'm trying to update user profile photos using this library.

The process includes uploading the photo as tmp file on my machine/server then uploading it to S3.

However, the tmp file gets cleared before it can be upoaded so I receive this error:

C:\\xampp\\tmp\/php808C.tmp does not exist

This is my code:

public function registerMediaConversions(\Spatie\MediaLibrary\Media $media = null ) {
    $this->addMediaConversion('thumb')->setManipulations( new Manipulations($this->thumb) );
    $this->addMediaConversion('large')->setManipulations(  new Manipulations($this->large) );
}


public function profilePhoto( $photo = null ) {
    if ( Ut::isUrl( $photo ) ) {
        return $this->clearMediaCollection( 'profile' )->addMediaFromUrl( $photo )->toMediaCollection( 'profile' );
    }

    if ( $photo instanceof UploadedFile ) {
        return $this->clearMediaCollection( 'profile' )->addMedia( $photo )->toMediaCollection( 'profile' );
    }
}

EDIT:

I have two types of users, one corporate and one regular. The corp user profile photo gets uploaded to a different tmp folder and goes up to S3 okay. As for the regular it goes to a different tmp folder and gets deleted quickly. So my question is how does Laravel decide where to put tmp files??



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire