0

I'm a little confused about Firebase. I have an application that is working fine with the default storage from Laravel. But I don't want any more content generated by my user to be on my server, so I'm thinking of using Firebase Cloud Storage Service. But I'm having some doubts.

This is my controller function that uploads to my server on Laravel when I receive an image file:

  if($request->hasFile('file')) {

                $mpFile = $request->file('file');
                $date  = Carbon::now();
                $year  = $date->year;
                $month = $date->month;
                $directory = $year . '/' . $month;

                $fileObj['filepath'] = Storage::disk('uploads')->put($directory,  $mpFile);
                $fileObj['fileName'] = basename($fileObj['filepath']);
                $exists   = Storage::disk('uploads')->exists($fileObj['filepath']);

                if($exists) {
                    $this->mdFile->store($fileObj, $categoryObj->mp_category_id);
                    $response["imgstatus"] = "Imagem anexada com sucesso";
                }else {
                    $response["imgstatus"] = "Não foi possível fazer o upload tente novamente";
                }

            }

When this happens I store in my database the file_path and file_name in association with the object ID reference on my database.

But I don't know how I will do this with Firebase, I must use Firebase on Laravel? to store the image and receive the file_path and file_name from Firebase? How I do this?

Or is it just another approach?

1 Answer 1

1

Check this documentation https://firebase.google.com/docs/storage/web/upload-files

You can upload images to firebase storage and get the download URL in return. You can save this path in the database you use.

There is nice tutorial in this link: https://angularfirebase.com/lessons/firebase-storage-with-angularfire-dropzone-file-uploader/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.