After an update form a previous version of video module, and installation of all the newly-required dependencies and libraries, it appeared, that the S3 component stopped pointing to Amazon S3 bucket. I have debugged some of the code, and it appears, that on the File System level, the module gets the paths in the bucket correctly. However, somewhere in the process, it spits out the server URL rather than the S3. Can you please point me o the parts of the code, where the logic of choosing local server might me happening? I promise to post my results.

Files: 
CommentFileSizeAuthor
#7 capture-041.png46.17 KBalexrayu

Comments

Status:Active» Postponed (maintainer needs more info)

The substitution of the local path to the S3 path happens in plugins/video_s3/filesystem/video_s3.inc in the load_file() method, line 34. Are you using Zencoder?

Thanks for a swift response. We are using Zencoder.

dpm($this->s3->get($video->fid)) returns:

    vid (String, 2 characters ) 51
    fid (String, 6 characters ) 110064
    nid (String, 4 characters ) 8681
    bucket (String, 6 characters ) vidtds
    filename (String, 43 characters ) sites/default/files/videos/aandamilonga.m4v
    filepath (String, 75 characters ) https://vidtds.s3.amazonaws.com/sites/default/f...
    filemime (String, 24 characters ) application/octet-stream
    filesize (String, 8 characters ) 95079713
    status (String, 2 characters ) 10
    completed (String, 10 characters ) 1320508076

And dpm($transcoder); returns

video_zencoder

In video_s3.inc in public function load_file(stdClass $video);

Title:Does not redirect to S3 after updateI think I found the problem

In public function load_file(stdClass $video) there is a line:

$file->url = $this->s3->getVideoUrl($file->filepath);

What that line does - it unconditionally assigns a local file path to URL, even though $file->url already contains the right S3 url.

I fixed my case by assigning filepath only if no S3 url exists:

if (!$file->url) $file->url = $this->s3->getVideoUrl($file->filepath);

Am I right or am I "short-circuiting" it?

I don't understand your comment. getVideoUrl should return an URL. The method is there because for authenticated URLs, the URL can't be stored in the database and has to be created when the URL is displayed.

What is the return value of $this->s3->getVideoUrl($file->filepath) ? What is the value of $file->filepath?

If you change if (strpos('/', $amazon->filename) !== FALSE && $transcoder == 'video_localcommand') { to if (strpos('/', $amazon->filename) !== FALSE) { and make no other changes compared to the release version, is it working?

Please see below.

StatusFileSize
new46.17 KB

This is what I get.

In the $video object, there are two paths that I see for extension "mov";
1. $video->files->mov->filepath is pointing to the file path on the local system.
2. $video->files->mov->url is pointing to the S3 URL that we need to use.

DPM Output

An then in the code below, what happens, is that getVideoUrl() function gets the URL from the local filepath, no the S3 URL.

<?php
$file
->url = $this->s3->getVideoUrl($file->filepath);
?>

So, even when there is an S3 url present, it returns a local filepath invariably. It may be, that the update did not go well. Is this making any sense? Should I provide more info?

Is that screenshot taken from a dpm() call after or before $file->url = $this->s3->getVideoUrl($file->filepath);?

I think I have found the problem and I would be very glad if you could try the following:

1. Change the file back to its original form.
2. On line 38 and 39 of video_s3.inc change $amazon to $file.
3. On line 38, remove && $transcoder == 'video_localcommand'.

The method now looks like:

  public function load_file(stdClass $video) {
    if ($amazon = $this->s3->get($video->fid)) {
      foreach ($video->files as $key => &$file) {
        $file->url = $this->s3->getVideoUrl($file->filepath);
        // For old video's (pre-4.5), the filename property is actually a path
        // and no locally converted files were saved to S3.
        if (strpos('/', $file->filename) !== FALSE) {
          $file->url = $s3->getVideoUrl($file->filename);
        }
      }
    }
  }

I know that ->url is already present at the start of the method. This is left over from previous versions of the module where the Amazon S3 URL was permanently stored in the database. This has been changed in 4.5, however, because when authenticated URLs are used, the URL must be generated dynamically.

Title:I think I found the problemFiles are not loaded from Amazon S3

I change the title back to a more descriptive one.

I have one more question. Does the original bug also occur for files that have been uploaded after you upgraded?

Category:support» bug
Status:Postponed (maintainer needs more info)» Fixed

Unfortunately, you have not responded to my questions. I am convinced that my fix works and I have committed it to 6.x-5.x and 6.x-4.x. Please reopen this issue if the fix doesn't work for you.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Thank you for your fix Jorrit. Sadly, the project got wrapped before I could do additional testing. But I am glad you were able to see the issue and apply the changes.