/// <summary> /// 图片点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Upload_Image_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog() { Filter = "图像文件|*.jpg;*.png;*.jpeg;*.bmp;*.gif|所有文件|*.*" }; if ((bool)openFileDialog.ShowDialog()) { QiniuUtil qiniuUtil = new QiniuUtil() { ConfigUtil = new Qiniu.Storage.Config(), TokenUtil = null }; string ret = qiniuUtil.ChunkUpload("chat_" + CommonUtil.GetTimeSecond() + "_msg." + CommonUtil.GetFileExtra(openFileDialog.SafeFileName), openFileDialog.FileName); JObject jObject = JObject.Parse(ret); ImageParam imageParam = new ImageParam() { Image = new Image() { Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(QiniuUtil.Domain + jObject["key"])), Opacity = 0 }, Bord = QiniuUtil.Domain + jObject["key"], Default = new DockPanel(), }; ChatingContent.Children.Add(imageParam.Dock); } }
public static void TestDownload() { string url = "http://static.ingoing.company.cn/TestImage"; QiniuUtil.DownloadFile(url, "D:/download.png", (int code) => { Debug.Log(code); }); }
private void AddVideoWindow_Loaded(object sender, RoutedEventArgs e) { string key = QiniuUtil.GenerateGuid(); TextFrontImg.SetKey(String.Format("{0}_videofrontimg", key)); TextVideo.SetKey(String.Format("{0}_video", key)); TextArtType.LoadData(); }
private void AddCrowFoundWindow_Loaded(object sender, RoutedEventArgs e) { string key = QiniuUtil.GenerateGuid(); TextFrontImg.SetKey(String.Format("{0}_crowdfundfrontimg", key)); CityControl.LoadData(); TextArtType.LoadData(); }
public void TestVideoCut() { string id = QiniuUtil.GenerateGuid(); var bl = ServerFileMgr.UploadFileToServer(id + "test58.mp4", @"D:\VID_20160429_130223.mp4", FileTypeDirEnum.CrowdFundVideoDir, false, null); Assert.AreEqual(bl.IsSuccess, true); //ServerFileMgr.VideoCutPiece(FileTypeDirEnum.VideoDir, "915d46db795459d6.mp4"); }
private void AddActorWindow_Loaded(object sender, RoutedEventArgs e) { string key = QiniuUtil.GenerateGuid(); TextHeadImg.SetKey(String.Format("{0}_userhead", key)); TextVideo.SetKey(String.Format("{0}_uservideo", key)); TextFrotImage.SetKey(String.Format("{0}_userfrontimg", key)); ComboBoxLoaction.LoadData(); }
public ApiResponse GetQiniuToken() { const uint expire = 60 * 60 * 24 * 30; DateTime expirationDate = DateTime.Now.AddDays(30); string token = QiniuUtil.GetUpToken(expire); // WriteLog(token); var model = new QiniuToken { Token = token, ExpirationTime = DateTimeConverter.ConvertDateTimeToDouble(expirationDate) }; return(new ApiResponse(Metas.SUCCESS, model)); }
public void TestGenerateId() { List <string> ls = new List <string>(); int count = 0; for (int i = 0; i < 1000; i++) { var id = QiniuUtil.GenerateGuid(); if (ls.Contains(id)) { count++; } ls.Add(id); } Assert.AreEqual(count, 0); }
private static void CallBackScreent(string msg) { QiniuUtil qiniuUtil = new QiniuUtil() { ConfigUtil = new Config(), TokenUtil = null }; string ret = qiniuUtil.ChunkUpload("chat_" + "screent_shot_" + CommonUtil.GetTimeSecond() + "_msg." + CommonUtil.GetFileExtra(msg), msg); JObject jObject = JObject.Parse(ret); Trace.WriteLine(jObject); CommonUtil.SetImage(QiniuUtil.Domain + jObject["key"]); }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { if (GetKey() == String.Empty) { return; } System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); openFileDialog1.Filter = QiniuUtil.GetFileFilter(UploadType); openFileDialog1.Multiselect = false; var re = openFileDialog1.ShowDialog(); if (re == System.Windows.Forms.DialogResult.OK) { var file = openFileDialog1.FileName; string filekey = string.Format("{0}{1}", GetKey(), System.IO.Path.GetExtension(file)); try { openFileDialog1.Dispose(); this.ProBar.Visibility = Visibility.Visible; Dowork dowork = DoUploadData; UploadData data = new UploadData(); data.Dir = UploadType; data.FileKey = filekey; data.Fpath = file; data.IsOverride = _isOverride; data.ProAction = OnProgress; dowork.BeginInvoke(data, Callback, dowork); } catch (Exception ex) { Trace.WriteLine(ex); } } }
public static void TestUpload() { //1.请求Token,添加header验证 Dictionary <string, string> form = new Dictionary <string, string>(); form.Add("Authorization", "Bearer 9701d8d0-f932-4648-8d08-1fc9fff8b895"); SimpleHttp.HttpPost(url, form, null, (WWW wwwInfo) => { Debug.Log(wwwInfo.text); /**{ * "code": 200, * "message": "success", * "data": { * "token": "xxxxxxxxxxxx" * }, * "timestamp": "1573436429382" * } */ JObject root = JObject.Parse(wwwInfo.text); int code = Convert.ToInt32(root["code"]); if (code == 200) { //2.获得uptoken string uptoken = Convert.ToString(root["data"]["token"]); string key = string.Format("u3d.{0}.target", root["timestamp"]); string filePath = Application.streamingAssetsPath + "/9924317EB4DC8E3E1A604108133F837D.target"; string persistPath = Application.persistentDataPath + "/9924317EB4DC8E3E1A604108133F837D.target"; File.Copy(filePath, persistPath, true); QiniuUtil.UploadFile(key, persistPath, uptoken, (string text) => { Debug.Log(text); }); } }); }
private string UploadFile(string pathName) { var file = pathName; string key = QiniuUtil.GenerateGuid(); string filekey = string.Format("{0}{1}", key, System.IO.Path.GetExtension(file)); try { ResultData result = ServerFileMgr.UploadFileToServer(filekey, file, _fileTypeDir, false, null); if (result != null && result.IsSuccess) { uploadFileList.Add(result.Key, _fileTypeDir); return(result.FullUrl); } } catch (Exception ex) { Trace.WriteLine(ex); } return(String.Empty); }
private void AddAppVersion_Loaded(object sender, RoutedEventArgs e) { string key = QiniuUtil.GenerateGuid(); TextUrl.SetKey(String.Format("{0}_android", key)); }