S3 does not return any errors but does not upload the file to the cloud

31 views Asked by At

Good friends, I have a problem when registering a file in S3 from Laravel, the point is that after putting the credentials in the .env when clicking on register it does not give me any error message but when I check in the cloud there is no file, here my code:

THIS MY FORM FILE

<div class="image-input image-input-outline image-input-placeholder " data-kt-image-input="true">
                                <!--begin::Preview existing avatar-->

                                <div class="image-input-wrapper w-125px h-125px" style="background-image: url();"></div>



                                <!--end::Preview existing avatar-->
                                <!--begin::Label-->
                                <label class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="change" data-bs-toggle="tooltip" title="Change avatar">
                                    {!! getIcon('pencil','fs-7') !!}
                                    <!--begin::Inputs-->
                                    <input type="file" wire:model="avatar" name="offer_image" id="offer_image" accept=".png, .jpg, .jpeg" />

                                    <!--end::Inputs-->
                                </label>
                                <!--end::Label-->
                                <!--begin::Cancel-->
                                <span class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="cancel" data-bs-toggle="tooltip" title="Cancel avatar">
                                    {!! getIcon('cross','fs-2') !!}
                                </span>
                                <!--end::Cancel-->
                                <!--begin::Remove-->
                                <span class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="remove" data-bs-toggle="tooltip" title="Remove avatar">
                                    {!! getIcon('cross','fs-2') !!}
                                </span>
                                <!--end::Remove-->
                            </div>

HERE IS THE ONE WHO PROCESSES IT

 public static function store(Request $request)
    {
        $token = session('authtokens')['access_token'];
        $status = ($request->status ?? "off") == "on" ? 1 : 0;

        $folder = "imagen";
       
        if ($request->hasFile('offer_image')) {
            
            
                       $filenamewithextension = $request->file('offer_image')->getClientOriginalName();
                 
                       $filename = pathinfo($filenamewithextension, PATHINFO_FILENAME);
                  
                       $extension = $request->file('offer_image')->getClientOriginalExtension();
               
                       $filenametostore = $filename.'_'.time().'.'.$extension;
                       
                        $oferta = Storage::disk('s3')->put($filenametostore, fopen($request->file('offer_image'), 'r+'));
                   //$url = Storage::url($folder);

          

When checking the cloud it does not make any shipments

1

There are 1 answers

0
Breno Pereira On

You are able to store a file from the request variable directly without having to open the file.

$path = $request->file('offer_image')->store('bucket');

You can also configure the default filesystem disk in your .env.

FILESYSTEM_DISK=s3

For more information, check out the File Uploads section.