• 七牛多文件压缩


    公司一个项目,需要用到七牛的多文件压缩功能,看了文档,有点懵,网上查代码,也没找到C#相关的,最后提了工单,在工程师的帮助下解决了这个问题。

                Mac mac = new Mac(AK, SK);
                Config config = new Config();
                OperationManager operationManager = new OperationManager(mac, config);
                //tmpImgUrl是在七牛已经存在的图片地址,后面是随机的一个图片名称,压缩包用的。
                string fops = "mkzip/2/url/" + Base64.UrlSafeBase64Encode(tmpImgUrl) + "/alias/" + Base64.UrlSafeBase64Encode(getRandomName());
                fops += "
    /url/" + Base64.UrlSafeBase64Encode(tmpImgUrl2) + "/alias/" + Base64.UrlSafeBase64Encode(getRandomName());
                fops += "
    /url/" + Base64.UrlSafeBase64Encode(tmpImgUrl3) + "/alias/" + Base64.UrlSafeBase64Encode(getRandomName());
                fops += "|saveas/" + Base64.UrlSafeBase64Encode(bucket + ":abc/down6.zip");//这里abc是设定下载文件的目录,down6是下载文件名称
                // 私有隊列名
                string pipeline = null;
                string notifyUrl = "http://api.example.com/qiniu/pfop/notify";//这是压缩成功的一个回调方法,我不需要使用,可以设置为空。
    
                // 文件名
                string key = "2018/07/12/1722443513";//这个比较坑,必须给一个目录已经存在的地址,随便给一个都行,这是pfop接口规格的强制要求
                // 当服务端发现 fops 指定的数据处理结果已经存在,那就认为已经处理成功,避免重复处理浪费资源。加上本字段并设为 1,则可强制执行数据处理并覆盖原结果。
                bool force = true;
                PfopResult pfopRet = operationManager.Pfop(bucket, key, fops, pipeline, notifyUrl, force);
                if (pfopRet.Code != (int)HttpCode.OK)//200表示成功,否则就看报错信息
                {
                    Console.WriteLine("pfop error: " + pfopRet.ToString());
                }

    另外,七牛提供的最新nuget包没有.net core的,所以这又是一个比较尴尬的事情。

    现在这个是基于七牛的nuget包7.3.1.1

  • 相关阅读:
    vcruntime140.dll 14.0与PHP版本不兼容,PHP Warning: 'vcruntime140.dll' 14.0 is not compatible with this PHP build linked with 14.16 in Unknown on line 0
    PHP处理字符中的emoji表情
    Thinkphp5 使用unlink删除文件出错Permission denied
    TP5多字段排序
    TP5 按照汉字的拼音排序
    PHP发送微信模版消息
    [52ABP系列]
    [52ABP系列]
    通过微信公众号实现微信快捷登陆
    [Jexus系列] 一、安装并运行 Jexus
  • 原文地址:https://www.cnblogs.com/xiaoquangege/p/9306819.html
Copyright © 2020-2023  润新知