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

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

        let 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;