Example #1
0
        public string upload(WebsiteInfo websiteInfo, string userId, Stream fileStream, string fileExtension)
        {
            string fileUrl = "";

            //判断是否有用到微软云
            if (HasWindowsAzure(websiteInfo))
            {
                //AZStorage.Client azClient = new AZStorage.Client("ehtwshopoos", "+8nN68pmvaGax4UqrowjKFbjKikPatgk/hLOZjDMzwJ8YORztDl3vQo2JyDnhYdWkEiJ4+4mXyP0KHA5gL2tOw==", "ehtwshopimg");
                AZStorage.Client azClient = new AZStorage.Client(websiteInfo.AzureAccountName, websiteInfo.AzureAccountKey, websiteInfo.AzureContainerName);
                fileUrl = azClient.upload(fileStream, fileExtension);
            }
            else
            {
                fileUrl = OssHelper.UploadFileFromStream(OssHelper.GetBucket(websiteInfo.WebsiteOwner), OssHelper.GetBaseDir(websiteInfo.WebsiteOwner), userId, "image", fileStream, fileExtension);
            }

            return(fileUrl);
        }