file-service.js 575 Bytes
const Context = require('../framework/context');

class FileService extends Context {
  constructor() {
    super();
  }
  getAbsoluteUrl(url, bucket) {
    if (!url) {
      return null;
    }

    const urlArr = url.split('/'),
      stag = urlArr[urlArr.length - 1].substr(0, 2),
      domain = `static.yhbimg.com/${bucket}`;

    url = domain + url;
    if (stag === '01') {
      return `http://img11.${url}`;
    } else if (stag === '03') {
      return `http://flv01.${url}`;
    } else {
      return `http://img12.${url}`;
    }
  }
}

module.exports = FileService;