public BosOpenStorageService(OssConfig config)
 {
     if (config == null)
     {
         throw new ArgumentNullException("config can not be null!");
     }
     _ossConfig                       = config;
     _clientConfiguration             = new BceClientConfiguration();
     _clientConfiguration.Credentials = new DefaultBceCredentials(config.AccessID, config.AccessKey);
     _clientConfiguration.Endpoint    = config.EndPoint;
     _bosClient                       = new BosClient(_clientConfiguration);
 }
예제 #2
0
        public static IList <OssConfig> GetAllConfigs()
        {
            IList <OssConfig> list;
            XmlDocument       doc = new XmlDocument();

            doc.Load(fileName);

            XmlNodeList nodes = doc.DocumentElement.SelectNodes("instant");

            list = new List <OssConfig>();
            foreach (XmlNode node in nodes)
            {
                OssConfig config = OssConfig.LoadByXmlNode(node);
                list.Add(config);
            }


            return(list);
        }
예제 #3
0
        /// <summary>
        /// 根据XML的节点实例化一个Oss Config对象
        /// </summary>
        /// <param name="node">XML节点</param>
        /// <returns></returns>
        internal static OssConfig LoadByXmlNode(XmlNode node)
        {
            OssConfig config = new OssConfig();

            config.Domain       = Utilities.SafeGetAttribute(node, "domain");
            config.ImageDomain  = Utilities.SafeGetAttribute(node, "imgdomain");
            config.AccessID     = Utilities.SafeGetAttribute(node, "accessId");
            config.AccessKey    = Utilities.SafeGetAttribute(node, "accessKey");
            config.IsLocalOss   = Utilities.SafeGetAttribute(node, "isLocalOss") == "true";
            config.RootFilePath = Utilities.SafeGetAttribute(node, "rootFilePath");
            config.BucketName   = Utilities.SafeGetAttribute(node, "bucketName");
            string skuids = Utilities.SafeGetAttribute(node, "skuIds");

            config.SupportSkuIds    = skuids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            config.EndPoint         = Utilities.SafeGetAttribute(node, "endPoint");
            config.ValidInDesign    = Utilities.SafeGetAttribute(node, "validInDesign") != "false";
            config.ValidInPublished = Utilities.SafeGetAttribute(node, "validInPublished") == "true";
            config.Platform         = Utilities.SafeGetAttribute(node, "platform");
            return(config);
        }
예제 #4
0
        static void Main(string[] args)
        {
            //配置文件

            DateTime updateDate = Convert.ToDateTime(getCurrentDay());                       //Convert.ToDateTime(System.Configuration.ConfigurationSettings.AppSettings[0]);
            string   FolderPath = System.Configuration.ConfigurationSettings.AppSettings[0];
            string   Pre_key    = System.Configuration.ConfigurationSettings.AppSettings[1]; //云盘上的key根目录

            OssConfig                config    = OssConfigMgr.GetOneConfig();
            BosOpenStorageService    bos       = new BosOpenStorageService(config);
            OssConfig                aliConfig = OssConfigMgr.GetConfig(2);
            AliyunOpenStorageService aos       = new AliyunOpenStorageService(aliConfig);

            OssConfig ali_hk_Config         = OssConfigMgr.GetConfig(3);
            AliyunOpenStorageService hk_aos = new AliyunOpenStorageService(ali_hk_Config);

            OssConfig ali_us_Config         = OssConfigMgr.GetConfig(4);
            AliyunOpenStorageService us_aos = new AliyunOpenStorageService(ali_us_Config);

            try
            {
                var flag1 = true; var which = "";
                while (flag1)
                {
                    Console.WriteLine("\n\n\n欢迎使用云梦云端帮助工具");
                    Console.WriteLine("请输入数字选择程序: \n1上传(支持百度) \n2删除(支持百度) \n3模版文件迁移(从阿里云到百度云) \n4整站文件多平台迁移(待完成) \n5模板文件迁移(从阿里香港云到百度) \n6 阿里云文件迁移(香港云到美国云)");
                    which = Console.ReadLine();
                    if (which != "1" && which != "2" && which != "3" && which != "5" && which != "6" && which != "temp")
                    {
                        continue;
                    }

                    Console.WriteLine(""); Console.WriteLine("");
                    switch (which)
                    {
                    case "1":
                        updateDate = RunUpload(updateDate, FolderPath, Pre_key, bos);
                        break;

                    case "2":
                        delete(bos);
                        break;

                    case "3":
                        TemplateTransfer(bos, aos);
                        break;

                    case "5":
                        TemplateTransfer(bos, hk_aos);
                        break;

                    case "6":
                        TemplateTransfer_forAliyun(hk_aos, us_aos);
                        break;

                    case "temp":
                        //TempFunction(us_aos);
                        VisitUSA();
                        break;
                    }
                }
            }
            catch (Exception ex) {
                LogHelper.CreateErrorLogTxt(ex.Message);
            }

            Console.Read();
        }
예제 #5
0
 /// <summary>
 /// 通过一个OSS配置初始化阿里云OSS
 /// </summary>
 /// <param name="config"></param>
 public AliyunOpenStorageService(OssConfig config)
 {
     _ossClient = new OssClient(config.EndPoint, config.AccessID, config.AccessKey);
     _ossConfig = config;
 }