yb / qiniu-file-for-typecho

将 Typecho 的附件保存至七牛云存储
42 stars 24 forks source link

增加 byte 流写入内容的考虑 #4

Open kraity opened 5 years ago

kraity commented 5 years ago

增加 byte 流写入内容的考虑 用于XMLRPC接口上传附件因为XMLRPC上传用的byte流写入数据 108行

$filename = $file['tmp_name'];
        if (!isset($filename)) return false;

将其删掉

116行到127行

if ($error == null)   .... else return false; 

将其改为

if (isset($file['bytes'])) {
            list($ret, $error) = $upManager->put($token, $option->savepath . $file['name'], $file['bytes']);
            if ($error == null) {
                return array(
                    'name' => $file['name'], 
                    'path' => $option->savepath . $file['name']  . ($option->imgstyle == '' ? '' : '-' . $option->imgstyle), 
                    'size' => $file['size'], 
                    'type' => $ext, 
                    'mime' => $file['mime']//Typecho_Common::mimeContentType($option->savepath . $file['name'])
                    );

            } else {
                return false;
            }

        } else {

        // 上传文件
        $filename = $file['tmp_name'];
        //if (!isset($filename)) return false;
        list($ret, $error) = $upManager->putFile($token, $option->savepath . $file['name'], $filename);
           if ($error == null) {
            return array(
                'name' => $file['name'], 
                'path' => $option->savepath . $file['name'] . ($option->imgstyle == '' ? '' : '-' . $option->imgstyle), 
                'size' => $file['size'], 
                'type' => $ext, 'mime' => Typecho_Common::mimeContentType($filename)
                );
                } else {
            return false;

           }

        }
jzwalk commented 4 years ago

Typecho Fans社区版已代更