private void uploadToCloud(string filename, string uploadFileName, Stream fileStream, Message msg, Channel chan, string file) { if (filename.EndsWith("png") || filename.EndsWith("jpeg") || filename.EndsWith("jpg") || filename.EndsWith("gif") || filename.EndsWith("bmp")) { try { msg.Type = MessageTypes.Image; var configuration = new AccountConfiguration("hscl3sr21", "773858917884263", "RWVBnZhCDPyOrKAYihbubppmZ4E"); var uploader = new Uploader(configuration); string publicId = Path.GetFileNameWithoutExtension(filename); var uploadResult = uploader.Upload(new UploadInformation(filename, fileStream) { PublicId = publicId, Format = filename.Substring(filename.Length - 3), }); //msg.Content = uploadResult.Url; msg.Content = filename; } catch (Exception ex) { //context.Response.Write("{ 'success': " + ex.Message + " }"); return; } } else { //upload to dropbox string cloudPath = "/" + chan.Name + "/" + filename; var result = _sessionState.DropboxShareFile(file, cloudPath); //_sessionState.AuthClient(); //var result = _sessionState.DropboxClient.UploadFileAsync(new FileResource(file), cloudPath).Result; msg.Content = result;//cloudPath; } }