0

I am using joedawson / youtube laravel package. I have an issue with the video upload. I first upload the video to my project folder using below code:

if ($this->uploaded_video) {

        $filename = $this->uploaded_video->getFilename();
        $this->uploaded_video->storeAs('public/instruction-videos', $filename);
    }
    

It's uploaded successfully to project folder and i can access the video in browser by getting the url from below code

$fullpath = asset('storage/instruction-videos/'.$filename);

I can see the video in browser by accessing the path which I get from the above code snippet.

I upload the video to youtube using below code

$video = Youtube::upload($fullpath, ['title'=> 'title','description' => 'description'],'unlisted');

But I get the below error when I upload it to youtube Screenshot from 2022-08-17 18-12-44

Martin
  • 22,212
  • 11
  • 70
  • 132
Naveed Ali
  • 1,043
  • 7
  • 15
  • The filesize error is referencing a localhost URI (127.0.0.1). If this is online on your Youtube account then it's almost certainly a Youtube glitch and will probably be fixed shortly. – Martin Aug 17 '22 at 13:42
  • i am trying it from yesterday. i probably think it is not related to youtube glitch if i am not wrong. – Naveed Ali Aug 17 '22 at 13:44
  • `filesize` does not work for HTTP URLs, only for file system paths. Likely the upload script uses it to determine with `Content-Length` header to send. See to it that you pass a local filesystem path to `Youtube::upload`, and not an HTTP URL. – CBroe Aug 17 '22 at 13:51
  • i have checked the local path as well. it show me the same error. let me try it again and i will edit the question accordingly. – Naveed Ali Aug 17 '22 at 13:53
  • `$fullpath = asset('storage/instruction-videos/'.$filename);` - the explicit purpose of `asset` is to create _URLs_. Wrong tool for the job here. You should probably be using `storage_path` – CBroe Aug 17 '22 at 13:53
  • which path should i use than? – Naveed Ali Aug 17 '22 at 13:54
  • i have tried this one as well `$fullpath = storage_path('public/instruction-videos/'.$filename);` but it's giving the same error – Naveed Ali Aug 17 '22 at 13:59
  • THe URL starting with `127.0.0.1` indicates that the file has been "uploaded" to a "local" path rather than a remote server. So, your video file has not been uploaded remotely and this is why Youtube can not load it. I do not know how laravel operates but I would suggest checking that your Laravel install has a correctly configured ***remote*** server to send the files to. Your browser will still load the video file because the browser is on your local machine so can access local files. – Martin Aug 17 '22 at 17:41

1 Answers1

0

Please enter path as a local path, not an http path.

$fullpath = '/var/www/html/project/storage/instruction-videos/ ~~~'

in the form

young2
  • 16
  • 2