taobao.fenxiao.product.image.upload 产品图片上传
        
        产品主图图片空间相对路径或绝对路径添加或更新，或者是图片上传。如果指定位置的图片已存在，则覆盖原有信息，如果位置为1,自动设为主图。
557437
def image_upload(self, product_id, position, session, pic_path=None, image=None):
        ''''''
        request = TOPRequest('taobao.fenxiao.product.image.upload')
        request['product_id'] = product_id
        request['position'] = position
        if pic_path!=None: request['pic_path'] = pic_path
        if image!=None: request['image'] = image
        self.create(self.execute(request, session), fields=['result','created'], models={'created':TOPDate})
        return self
318456
def upload(token, end_point, input_file_path)
      #相対パスがきた時のために絶対パスに変換
      path_name_obj = Pathname.new(input_file_path);
      file_path = path_name_obj.expand_path.to_s
      mime = MIME::Types.type_for(file_path)[0]
      auth_header =
          if mime.nil?
            {'X-Auth-Token' => token}
          else
            {'X-Auth-Token' => token,
             'Content-Type' => MIME::Types.type_for(file_path)[0].to_s
            }
          end

      auth_header['X-Web-Mode'] = 'true' if @web_mode

      http_client = HTTPClient.new
      http_client.send_timeout = @send_timeout.to_i unless(@send_timeout.nil?)

      target_url = add_filename_to_url(end_point, file_path)

      puts 'upload_url -> ' + target_url

      if @delete_at
        auth_header['X-Delete-At'] = @delete_at
      end
      if @delete_after
        auth_header['X-Delete-After'] = @delete_after
      end
      if @meta_data_hash
        create_meta_data_header(auth_header, @meta_data_hash)
      end

      if File::ftype(file_path) == 'directory'
        auth_header['Content-Length'] = 0
        auth_header['Content-Type'] = 'application/directory'
        if @web_mode
          if @web_file_listing
           auth_header['X-Container-Read'] = '.r:*' + ',.rlistings'
           auth_header['X-Container-Meta-Web-Index'] = 'index.html'
          else
            auth_header['X-Container-Read'] = '.r:*'
          end
          #auth_header['X-Container-Meta-Web-Listings'] = 'true'
          #auth_header['X-Container-Meta-Web-Listings-CSS'] = 'listing.css'
        end
        p auth_header
        @res = http_client.put(URI.parse(URI.encode(target_url)), file_path, auth_header)
        if @res.status == UPLOAD_SUCCESS_HTTP_STATUS_CODE
          Dir::foreach(file_path) {|f|
            next if (f == '.' || f == '..')
            begin
              child_path = path_name_obj.join(f)
              # 再帰
              upload(token, add_filename_to_url(end_point, File::basename(file_path)), child_path)
            rescue => e
              puts e
            end
          }
        end
      else
        p auth_header

        if LargeObject::StaticLargeObject.is_over_default_limit_object_size(File.size(file_path))
          #Auto SLO Mode
          p File.size(file_path)
          puts '------ Over limit object size! change Static Large Object Mode. ------- '
          LargeObject::Slo_client.new(self, input_file_path, end_point).upload
        else
          File.open(file_path) do |file|
            @res = http_client.put(URI.parse(URI.encode(target_url)), file, auth_header)
          end
        end

      end

      #p @res
      @res.status
    end
687280
function getPublishFile(selectedFile) {
        console.log('你需要发布文件如下：');
        
        var files = [];
        selectedFile.forEach(function(file, idx) {
            console.log('  [' + (idx + 1) + ']' + file);
            files.push(file);
        });
        
        prepareBatchPubFiles(awpConfig, pubConfig, files);

    }
14166
public void deleteUploadFile(HttpServletRequest request,
                               UploadFile uploadFile) {
    try {
      String imageId = null;
      //首先先删除Session
     if (!UtilValidate.isEmpty(uploadFile.getTempId())) {
        imageId = uploadFile.getTempId();
        deleteUploadFileFromSession(request, imageId);
      }else  if (!UtilValidate.isEmpty(uploadFile.getId())) {
       imageId = uploadFile.getId();
       deleteUploadFileFromSession(request, imageId);
       imageFilter.deleteUploadFile(request, uploadFile);
      } else
        throw new Exception("parameter id  and tempId all is null");

    } catch (Exception ex) {
      Debug.logError("[JdonFramework] deleteUploadFile error:" + ex, module);
    }

  }
213912
private void uploadThumbImage(StorageNode client, InputStream inputStream, String masterFilename,
                                  String fileExtName) {
        ByteArrayInputStream thumbImageStream = null;
        try {
            thumbImageStream = generateThumbImageByDefault(inputStream);// getFileInputStream
            // 获取文件大小
            long fileSize = thumbImageStream.available();
            // 获取缩略图前缀
            String prefixName = thumbImageConfig.getPrefixName();
            LOGGER.debug("上传缩略图主文件={},前缀={}", masterFilename, prefixName);
            StorageUploadSlaveFileCommand command = new StorageUploadSlaveFileCommand(thumbImageStream, fileSize,
                    masterFilename, prefixName, fileExtName);
            connectionManager.executeFdfsCmd(client.getInetSocketAddress(), command);

        } catch (IOException e) {
            LOGGER.error("upload ThumbImage error", e);
            throw new FdfsUploadImageException("upload ThumbImage error", e.getCause());
        } finally {
            IOUtils.closeQuietly(thumbImageStream);
        }
    }
907665
function(val, index, rule){
    //存在url，并且url不是http方式
    var isHttpUrl = val.indexOf('//') > -1;
    var ret = false;
    if (!isHttpUrl){
      var uri = imageUrlReg.exec(val);
      if (uri){
        var imgurl = url.parse(uri[1], true);
        var params = imgurl.query;
        var id = params['id'] || 0;
        ret = imgurl.pathname.replace(/\\+/g, '/');
        //过滤图片
        if (!(PARAMS['nosprite'] in params)){
          //设置第一个图片为sprite图片位置
          if (!this.get('imgPath')){
            this.set('imgPath', path.dirname(ret));
          }

          var preParam = this.get('preParam');
          var _id = this.get('id');
          if (_id == id){
            this.initSpriteConf(params);
            //依次初始化图片配置
            preParam.forEach(this.initSpriteConf, this);
            preParam = [];
          } else if (_id < id){
            //如果id提前出现，既id为0的图片没有出现之前，id是1的已经出现了，把
            //当前参数存在数组preParam中
            var isNewImg = preParam.every(function(params){
              return params.id < id;
            });
            if (isNewImg) preParam.push(params);
          }
          this.set('preParam', preParam);
        } else {
          var cssImgs = this.get('cssImgs');
          cssImgs.push(ret);
          rule.value[index] = val.replace(imgurl.pathname, ret);
          ret = false;
        }
      }
    }

    return ret;
  }
269363
function addFile(file) {
            var $li = $('<li id="' + file.id + '">' +
                '<p class="title">' + file.name + '</p>' +
                '<p class="imgWrap"></p>' +
                '<p class="progress"><span></span></p>' +
                '</li>'),

                $btns = $('<div class="file-panel">' +
                    '<span class="cancel">删除</span>' + '</div>').appendTo($li),
                $prgress = $li.find('p.progress span'),
                $wrap = $li.find('p.imgWrap'),
                $info = $('<p class="error"></p>'),

                showError = function(code) {
                    switch (code) {
                        case 'interrupt':
                            text = '上传暂停';
                            break;

                        default:
                            text = '上传失败，请重试';
                            break;
                    }

                    $info.text(text).appendTo($li);
                };

            if (file.getStatus() === 'invalid') {
                showError(file.statusText);
            } else {
                $wrap.text('不能预览');
                percentages[file.id] = [file.size, 0];
                file.rotation = 0;
            }

            file.on('statuschange', function(cur, prev) {
                if (prev === 'progress') {
                    $prgress.hide().width(0);
                } else if (prev === 'queued') {
                    $li.off('mouseenter mouseleave');
                    $btns.remove();
                }

                // 成功
                if (cur === 'error' || cur === 'invalid') {
                    showError(file.statusText);
                    percentages[file.id][1] = 1;
                } else if (cur === 'interrupt') {
                    showError('interrupt');
                } else if (cur === 'queued') {
                    percentages[file.id][1] = 0;
                } else if (cur === 'progress') {
                    $info.remove();
                    $prgress.css({
                        display: 'block',
                        width: '10%'
                    });
                } else if (cur === 'complete') {
                    $li.append('<span class="success"></span>');
                }

                $li.removeClass('state-' + prev).addClass('state-' + cur);
            });

            $li.on('mouseenter', function() {
                $btns.stop().animate({
                    height: 30
                });
            });

            $li.on('mouseleave', function() {
                $btns.stop().animate({
                    height: 0
                });
            });

            $btns.on('click', 'span', function() {
                uploader.removeFile(file);
            });

            $li.appendTo($queue);
        }
1133829
function(url, filepath, fn){
        // 提交请求
        try{
            fs.createReadStream(filepath).pipe(request.post(url, fn))
        }
        catch(e){ fn(e) }
    }
881503
function (params, successCallback, failCallback) {
    var t$ = this;
    if (!t$._check(params.productIdentifier)) { return }

    // ////////////////////////////////////////////////////////////////////////////
    var _cb = function (obj) {
      try {
        $bc_$2.IAP.NoticeCenter().remove(_cb);
        if (lodash.isObject(obj)) {
          var info = obj.info;
          var notifyType = obj.notifyType;

          if (info.productIdentifier === params.productIdentifier) {
            if (notifyType === t$.MessageType['ProductPurchased']) {
              successCallback && successCallback(info.productIdentifier, obj);
            } else if (t$.MessageType['ProductPurchaseFailed']) {
              failCallback && failCallback(info.productIdentifier, obj);
            }
          }
        }
      } catch (e) {
        console.error(e);
      }
    };

    // 注册一个消息回调
    $bc_$2.IAP.NoticeCenter().add(_cb);

    if ($bc_$2.pN) {
      // 发送购买请求
      $bc_$2.pN.iap.buyProduct(JSON.stringify({
        identifier: params.productIdentifier,
        quantity: params.quantity || 1
      }));
    } else {
      console.log('Romanysoft SDK simulation environment....');
      var obj = window.localStorage.getItem($bc_$2.IAP_SE_KEY) || JSON.stringify({});

      $bc_$2.IAP_SE_OBJ = JSON.parse(obj);
      var orgQuantity = 0;
      var saveQuantity = 0;
      if ($bc_$2.IAP_SE_OBJ[params.productIdentifier]) {
        orgQuantity = $bc_$2.IAP_SE_OBJ[params.productIdentifier];
        saveQuantity = orgQuantity + params.quantity || 1;
      } else {
        saveQuantity = params.quantity || 1;
      }

      $bc_$2.IAP_SE_OBJ[params.productIdentifier] = saveQuantity;
      window.localStorage.setItem($bc_$2.IAP_SE_KEY, JSON.stringify($bc_$2.IAP_SE_OBJ));

      // 模拟发送成功购买信息
      $bc_$2.IAP_SE_Wrapper.caller().fire({
        notifyType: t$.MessageType['ProductPurchased'],
        info: {
          productIdentifier: params.productIdentifier,
          quantity: saveQuantity
        }
      });

      // 模拟发送购买完成信息
      $bc_$2.IAP_SE_Wrapper.caller().fire({
        notifyType: t$.MessageType['ProductCompletePurchased'],
        info: {
          productIdentifier: params.productIdentifier,
          transactionId: 'transactionId' + Math.round(999),
          receipt: 'receipt' + Math.round(999)
        }
      });
    }
  }
65153
function getApiResult(data, status, message) {
    var result = {};

    // 成功处理并返回
    if (!status) {
        result.data = data;
    } else {
        result.status = status;
        result.statusInfo = {
            message: message
        };
    }

    return result;
}
1107651
private static function value_preiew(){
        $attr = self::$attr;

        if(!strlen(self::$attr['value'])) return '';

        if($attr['multiple'] == 'on' || $attr['multiple'] == 1){
            $attr['name'] = $attr['name'].'[]';
        }
        $str = '';
        $arr = explode(',',self::$attr['value']);

        switch ($attr['uploadtype']){
            case 'image':
                foreach($arr as $k => $v){
                    $str .= <<<EOT
<div class="preiew_item already_upload"  style="display: block;">
    <i class="layui-icon del_up_pic">ဆ</i>
    <input type="hidden" name="{$attr['name']}" value="{$v}">
    <img src="{$v}">
    <div class="upinfo" style="display: block;">
        <div class="layui-progress">
            <div class="layui-progress-bar" lay-percent="100%" style="width: 100%;"></div>
        </div>
        <span class="layui-btn layui-btn-xs" style="width: 100%;color: #FFFFFF;">已上传</span>
    </div>
</div>
EOT;

                }
                break;
            case 'file':

                foreach($arr as $k => $v){
                    //文件不存在  跳过
                    if(!file_exists(ROOT_PATH.$v))continue;

                    $File = new File(ROOT_PATH.$v);
                    $size = self::sizecount($File->getSize());
                    $str .=<<<EOT
<tr class="already_upload">
    <td>{$File->getBasename()} </td>
    <td>{$size}</td>
    <td class="file_upinfo">
        <div class="info">已上传</div>
        <div class="layui-progress">
            <div class="layui-progress-bar" lay-percent="100%" style="width: 100%;"></div>
        </div>
    </td>
    <td>
        <span class="layui-btn del_up_file">删除</span>
    </td>
    <input type="hidden" name="{$attr['name']}" value="{$v}"></tr>
EOT;

                    //释放对象
                    unset($File);
                }
                break;
        }

        return $str;
    }
797283
function prepareBatchPubFiles(awpConfig, pubConfig, filePaths) {

        "use strict";

        awpConfig.group = awpConfig.group || 'o2o';

        var onlinePath,
            isPathInvalid;

        if(filePaths.length == 0) {
            console.log(error('您没有选中任何要发布的文件，请重新执行命令进行选择!'));
            process.exit(0);
        }

        console.log('您将要发布以下文件：');

        filePaths.forEach(function(filePath, idx) {
            var fileName = filePath.replace('./htmls-dist/', '');

            // 映射到的发布地址
            onlinePath = concatPubPath(pubConfig.env, fileName);

            // 是否包含不合法的字符串
            isPathInvalid = checkFileValid(onlinePath);

            // 打印确认
            console.log(isPathInvalid ? success(filePath) : warn(filePath));
            console.log(isPathInvalid ? success('    -> ' + clc.underline(onlinePath)) : warn('    -> ' + clc.underline(onlinePath)));

        });

        // 开始全部发布
        filePaths.forEach(function(filePath, i) {
            batchPubFiles(awpConfig, pubConfig, filePath);
        });

    }
1053728
def get(self, nick, fields=[], props=None, page_no=None, page_size=None):
        ''''''
        request = TOPRequest('taobao.products.get')
        request['nick'] = nick
        if not fields:
            product = Product()
            fields = product.fields
        request['fields'] = fields
        if props!=None: request['props'] = props
        if page_no!=None: request['page_no'] = page_no
        if page_size!=None: request['page_size'] = page_size
        self.create(self.execute(request))
        return self.products
891666
function sliceInit(opt) {
        var defer = $.Deferred();
        var file = opt.file;
        var that = this;

        var url = this.getCgiUrl(opt.path, opt.sign);

        var formData = new FormData();
        var uploadparts = opt.uploadparts;
        formData.append('uploadparts', JSON.stringify(uploadparts));
        formData.append('sha', opt.sha);
        formData.append('op', 'upload_slice_init');
        formData.append('filesize', file.size);
        formData.append('slice_size', opt.sliceSize);
        formData.append('biz_attr', opt.biz_attr);
        formData.append('insertOnly', opt.insertOnly);

        $.ajax({
            type: 'POST',
            dataType: "JSON",
            url: url,
            data: formData,
            success: function (res) {
                if (opt.globalTask.state === 'cancel') return;
                res = res || {};
                if (res.code == 0) {

                    if (res.data.access_url) {//如果秒传命中则直接返回
                        defer.resolve(res);
                        return;
                    }
                    var session = res.data.session;
                    var sliceSize = parseInt(res.data.slice_size);

                    var offset = res.data.offset || 0;

                    opt.session = session;
                    opt.slice_size = sliceSize;
                    opt.offset = offset;

                    sliceUpload.call(that, opt).done(function (r) {
                        defer.resolve(r);
                    }).fail(function (r) {
                        defer.reject(r);
                    });

                    // 保存正在上传的 session 文件分片 sha1，用于下一次续传优化判断是否不一样的文件
                    var sItem, sha1Samples = {};
                    for (var i = 1; i < opt.uploadparts.length; i *= 2) {
                        sItem = opt.uploadparts[i - 1];
                        sha1Samples[sItem.offset + '-' + sItem.datalen] = sItem.datasha;
                    }
                    sItem = opt.uploadparts[opt.uploadparts.length - 1];
                    sha1Samples[sItem.offset + '-' + sItem.datalen] = sItem.datasha;
                    rememberSha1(opt.session, sha1Samples, that.sha1CacheExpired);

                } else {
                    defer.reject(res);
                }
            },
            error: function () {
                defer.reject();
            },
            processData: false,
            contentType: false
        });

        return defer.promise();
    }
67073
function generateImage({
    fontSize = null,
    color = '#fff',
    background = '#616161',
    text = '',
    size = [600, 200],
  }) {
    const width = size[0],
      height = size[1],
      fontFamily = 'sans-serif';

    if (!fontSize) { // 取宽度的 1/8
      fontSize = (width / 8).toFixed();
    }
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

    canvas.width = width;
    canvas.height = height;
    ctx.fillStyle = background;
    ctx.fillRect(0, 0, width, height);

    // 背景上设置小点
    ctx.fillStyle = contrast(background);
    const pointX = width / 2;
    const pointY = height / 2;
    for (let i = 0; i < pointY; i++) {
      for (let j = 0; j < pointX; j++) {
        ctx.fillRect(i * 20 + 9, j * 20 + 9, 2, 2);
      }
    }

    ctx.textAlign = 'center';
    ctx.textBaseline = 'middle';
    ctx.fillStyle = color;
    ctx.font = `bold ${fontSize}px ${fontFamily}`;
    ctx.fillText(text, (width / 2), (height / 2), width);

    return canvas.toDataURL('image/png');
  }
1001777
public function create()
    {
        if ($this->bgImage && is_file($this->bgImage)) {
            // 从背景图片建立背景画布
            $this->img = imagecreatefrompng($this->bgImage);
        } else {
            // 手动建立背景画布,图像资源
            $this->img = imagecreatetruecolor($this->width, $this->height);

            //给画布填充矩形的背景色rgb(230, 255, 230);
            $bgColor = $this->bgColor;

            //背景色
            $bgColor = imagecolorallocate(
                $this->img, hexdec(substr($bgColor, 1, 2)),
                hexdec(substr($bgColor, 3, 2)), hexdec(substr($bgColor, 5, 2))
            );

            imagefilledrectangle($this->img, 0, 0, $this->width, $this->height, $bgColor);
        }

        //给资源画上边框-可选 rgb(153, 153, 255)
//        $borderColor = imagecolorallocate($this->img, 153, 153, 255); // 0-255
//        imagerectangle($this->img, 0, 0, $this->width-1, $this->height-1,$borderColor);

        $this->drawLine();
        $this->drawChar();
        $this->drawPixel();
        $this->drawChars();

        return $this;
    }
807752
function updateAbcFile() {
		var content = '<version> */';
		abc_allname.sort().forEach(function (name) {
			if (abc_name2ver[name]) {
				content += '\r\n"'+name.slice(0, -3)+'": "'+abc_name2ver[name]+'",';
				if (abc_isnew[name]) {
					content += ' /*new*/';
					name.indexOf('/')>0 && util.mkdir(path_tag, name);
				} else if (abc_name2ver[name].indexOf(abc_newverstr)===0) {
					content += ' /*u*/';
					name.indexOf('/')>0 && util.mkdir(path_tag, name);
				} else {
					delete abc_name2ver[name];
					return;
				}
				delete abc_name2ver[name];
				//复制有变化的文件
				sfs.copy(path_min+name, path_tag+name);
			}
		});
		var deleted = [], k;
		for (k in abc_name2ver) {
			content += '\r\n/*"'+k.slice(0, -3)+'": "'+abc_name2ver[k]+'", del*/';
			deleted.push(k);
		}
		content = abc_a+content+'\r\n/* </version>'+abc_c;
		sfs.write(path_tag+boot_js, content);
		sfs.write(path_min+boot_js, content); //复制boot_js文件到min目录下
		//复制abc.js文件到打包项目的目录下，命名为update-abc.js，
		//提交SVN时先删除已有的abc.js，
		//再把update-abc.js重命名为abc.js，即实现更新abc.js
		sfs.write(prj_path+'updated-'+boot_js, content);
		
		deleted.length &&
			response.write('<br/>MOKJS-601: 有main文件被删除了：'+deleted.join(', '));
	}