You are here

public function video_s3::onpreconvert in Video 6.5

Return value

bool FALSE if an error occured while doing the operation, TRUE when no operation was needed or on success

Overrides video_filesystem::onpreconvert

File

plugins/video_s3/filesystem/video_s3.inc, line 266
Class file used to store videos in Amazon S3.

Class

video_s3

Code

public function onpreconvert(stdClass $video) {
  if ($this->s3
    ->verify($video->fid)) {

    // The file is already inserted
    return FALSE;
  }
  db_query('INSERT INTO {video_s3} (fid, status) VALUES (%d, %d)', $video->fid, VIDEO_S3_ACTIVE);

  // Push the original file, but leave it on the local disk for the local transcoder
  if ($this->s3
    ->pushFile($video, TRUE) != NULL) {
    db_query('UPDATE {video_s3} SET bucket="%s", filename="%s", filepath="%s", filemime="%s", filesize="%s", status=%d, completed=%d WHERE fid=%d', $video->bucket, $video->filename, $video->filepath, $video->filemime, $video->filesize, VIDEO_S3_COMPLETE, time(), $video->fid);
    return TRUE;
  }
  db_query('UPDATE {video_s3} SET status = %d WHERE fid=%d', VIDEO_S3_FAILED, $video->fid);
  return FALSE;
}