//file Upload to the Google Drive.
        public static string FileUpload(string tenbaihat, string tentacgia, HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                Google.Apis.Drive.v3.DriveService service = GetService();

                string path = Path.Combine(HttpContext.Current.Server.MapPath("~"),
                                           Path.GetFileName(file.FileName));

                file.SaveAs(path);

                String       signature = "";
                WaveSteg     filess    = new WaveSteg(new FileStream(path, FileMode.Open, FileAccess.Read));
                StagnoHelper sh        = new StagnoHelper(filess);
                signature = sh.ExtractMessage();

                var FileMetaData = new Google.Apis.Drive.v3.Data.File();
                FileMetaData.Name     = Path.GetFileName(file.FileName);
                FileMetaData.MimeType = MimeMapping.GetMimeMapping(path);

                Google.Apis.Drive.v3.FilesResource.CreateMediaUpload request;

                using (var stream = new System.IO.FileStream(path, System.IO.FileMode.Open))
                {
                    request        = service.Files.Create(FileMetaData, stream, FileMetaData.MimeType);
                    request.Fields = "id";
                    request.Upload();
                }
                var fileresponse = request.ResponseBody.Id;


                //Get id to server
                var dao    = new UserDao();
                var result = dao.UploadMusic(tenbaihat, tentacgia, fileresponse);
                if (result == 1)
                {
                    return(signature);
                }
            }
            return("");
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes this StagnoHelper object with WaveAudio object.
 /// </summary>
 /// <param name="file">WaveAudio object to be initilized.</param>
 public StagnoHelper(WaveSteg file)
 {
     this.file = file;
 }