/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private UploadFileType EntityGet() { UploadFileType entity = new UploadFileType(); entity.ID = HTDataID; return(entity); }
public async Task <Response> GetUploadInfos(UploadFileType uploadFileType) { try { var result = await client.Child("UploadInfo").OrderByKey().OnceAsync <UploadInfo>(); var uploadInfos = new ObservableCollection <UploadInfo>(); foreach (var item in result) { var uploadInfo = item.Object as UploadInfo; if (uploadInfo.Type == uploadFileType.ToString()) { uploadInfos.Add(new UploadInfo { DateTime = uploadInfo.DateTime, DownloadLink = uploadInfo.DownloadLink }); } } return(new Response { Success = true, UploadInfos = uploadInfos }); } catch (Exception ex) { return(new Response { Success = false }); } }
/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { UploadFileType MasterEntity = (UploadFileType)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Enum_UploadFileType WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(Sql); } else { AffectedRows = sqlTrans.ExecuteNonQuery(Sql); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBDelete), E); } }
/// <summary> /// <para> /// Uploads oversize content (template or policy) to S3. /// </para> /// This method will be called by create/update operations to upload oversize content to S3. /// <para></para> /// </summary> /// <param name="stackName">Name of the stack. Use to form part of the S3 key</param> /// <param name="body">String content to be uploaded.</param> /// <param name="originalFilename">File name of original input file, or <c>"RawString"</c> if the input was a string rather than a file</param> /// <param name="uploadFileType">Type of file (template or policy). Could be used to form part of the S3 key.</param> /// <returns> /// URI of uploaded template. /// </returns> public async Task <Uri> UploadOversizeArtifactToS3( string stackName, string body, string originalFilename, UploadFileType uploadFileType) { using (var ms = new MemoryStream( new UTF8Encoding().GetBytes(body ?? throw new ArgumentNullException(nameof(body))))) { var bucket = await this.GetCloudFormationBucketAsync(); var key = uploadFileType == UploadFileType.Template ? this.timestampGenerator.GenerateTimestamp() + $"_{stackName}_template_{originalFilename}" : this.timestampGenerator.GenerateTimestamp() + $"_{stackName}_policy_{originalFilename}"; var ub = new UriBuilder(bucket.BucketUri) { Path = $"/{key}" }; this.logger.LogInformation($"Copying oversize {uploadFileType.ToString().ToLower()} to {ub.Uri}"); await this.s3.PutObjectAsync( new PutObjectRequest { BucketName = this.cloudFormationBucket.BucketName, Key = key, AutoCloseStream = true, InputStream = ms }); return(ub.Uri); } }
public async void UploadFile(string filePath, UploadFileType uploadFileType, IUploadCallback uploadCallback) { FileStream fileStream = null; try { await Task.Run(() => { fileStream = File.Open(filePath, FileMode.Open); }); var fileName = Path.GetFileName(filePath); var uploadTask = storageClient.Child(uploadFileType.ToString()).Child(fileName).PutAsync(fileStream); uploadTask.Progress.ProgressChanged += (s, e) => uploadCallback.SetUploadPercentage(e.Percentage); var downloadLink = await uploadTask; InsertUploadInfo(new UploadInfo { Type = uploadFileType.ToString(), DownloadLink = downloadLink }); uploadCallback.UploadCompleted(); } catch (Exception ex) { uploadCallback.SetUploadPercentage(-1); } }
public FileUpload(Guid projectGuid, UploadFileType uploadFileType, string filename, string path) { this.filename = filename; this.projectGuid = projectGuid; type = uploadFileType; this.path = path; }
/// <summary> /// 删除 /// </summary> public override void EntityDelete() { UploadFileTypeRule rule = new UploadFileTypeRule(); UploadFileType entity = EntityGet(); rule.RDelete(entity); }
/// <summary> /// 检查文件是否已保存成功,在3s内检查到保存的文件才会进行上传操作 /// </summary> private IEnumerator CheckAndUpload(string outputPath, string name, UploadFileType fileType) { Debug.Log("CheckUpload!!!!"); if (GetCurrentAlbumProfileName() == null) { Debug.LogWarning("CurrentAlbumProfileName is null"); StopCoroutine("CheckAndUpload"); } float checkTime = 0; while (!File.Exists(outputPath + name) && checkTime < limitTime) { checkTime += 0.1f; yield return(new WaitForSeconds(0.1f)); } if (File.Exists(outputPath + name)) { Debug.Log("开始上传到Server"); if (GetCurrentAlbumProfileName() != null) { StartCoroutine(UploadToServer(outputPath, name, GetCurrentAlbumProfileName(), fileType)); } else { Debug.Log("currentAlbumProfileName is null"); } } else { SetStatusErrorText("检查该文件是否存在,文件地址 : " + outputPath + name); } }
public static Java.IO.File GetOutputMediaFile(UploadFileType type) { string extr = Android.OS.Environment.ExternalStorageDirectory.ToString(); Java.IO.File mFolder = new Java.IO.File(extr + "/TMMFOLDER"); if (!mFolder.Exists()) { mFolder.Mkdir(); } String timeStamp = new Java.Text.SimpleDateFormat("yyyyMMdd_HHmmss", Locale.Default).Format(new Date()); Java.IO.File mediaFile; if (type == UploadFileType.image) { mediaFile = new Java.IO.File(mFolder.AbsolutePath + Java.IO.File.Separator + "IMG_" + timeStamp + ".jpg"); } else { mediaFile = new Java.IO.File(mFolder.AbsolutePath + Java.IO.File.Separator + "VID_" + timeStamp + ".mp4"); } return(mediaFile); }
/// <summary> /// 检查文件是否已保存成功,在3s内检查到保存的文件才会进行上传操作 /// </summary> private IEnumerator CheckAndUpload(string outputPath, string name, UploadFileType fileType) { float checkTime = 0; while (!File.Exists(outputPath + name) && checkTime < 3f) { checkTime += 0.1f; yield return(new WaitForSeconds(0.1f)); } if (File.Exists(outputPath + name)) { Debug.Log("开始上传到Server"); if (CurrentAlbumName != null) { StartCoroutine(UploadToServer(outputPath, name, CurrentAlbumName, fileType)); } else { KeyValueUpdate kvs = new KeyValueUpdate(SysDefine.MESSAGE_InfomationTypeNormal, "currentAlbumProfileName is null"); MessageCenter.SendMessage(SysDefine.MESSAGE_Infomation, kvs); } } else { Debug.Log("检查该文件是否存在,文件地址 : " + outputPath + name); } }
public static string UploadFile(UploadFileType uploadFileType, string filePath, string orderNumber) { FileUploader uploader = new FileUploader(); // Create 2501 directory uploader.CreateDirectory(orderNumber); string fileName = ""; switch (uploadFileType) { case UploadFileType.ZipFile: fileName = $"{orderNumber}zip.csv"; break; case UploadFileType.TestSeedFile: fileName = $"{orderNumber}test.csv"; break; case UploadFileType.LiveSeedFile: fileName = $"{orderNumber}live.csv"; break; case UploadFileType.SuppressionFile: fileName = $"{orderNumber}supp.csv"; break; } return(uploader.Upload(orderNumber, fileName, filePath)); }
public FileHandler(string filename, UploadFileType type, string uniqueid) { this.filename = filename; string folder = ""; filetype = type; switch (type) { case UploadFileType.DIGITAL: folder = string.Format("/Uploads/files/{0}/digital", uniqueid); break; case UploadFileType.IMAGE: folder = string.Format("/Uploads/files/{0}/images", uniqueid); break; case UploadFileType.MOBILE_THEME: folder = string.Format("/Uploads/files/{0}/mobile_theme", uniqueid); break; case UploadFileType.THEME: folder = string.Format("/Uploads/files/{0}/theme", uniqueid); break; } // create folder if it doesn't exist if (!Directory.Exists(GeneralConstants.APP_ROOT_DIR + folder)) { Directory.CreateDirectory(GeneralConstants.APP_ROOT_DIR + folder); } url = string.Format("{0}/{1}", folder, filename); }
public static string SaveUploadeFile(AsyncFileUpload fup, string SaveFolder, UploadFileType filetype, UploadFileSizeLimitation filesizelimit, UploadImageSize? Imagesize = null) { string FileExtension = Path.GetExtension(fup.FileName); if (!IsValidFileType(FileExtension, filetype)) { MessageBoxHelper.ShowMessageBox(fup.Page, "نوع فایل نامعتبر است", "", MessageBoxType.Information); return null; } if (!IsValidFileSize(fup.FileBytes.Length.ToLong(), filesizelimit)) { MessageBoxHelper.ShowMessageBox(fup.Page, "حجم فایل نامعتبر است", "", MessageBoxType.Information); return null; } MemoryStream memStream = Imagesize.HasValue ? ResizeImage(fup.FileBytes, Imagesize.Value, FileExtension) : new MemoryStream(fup.FileBytes); string FileName = Path.GetFileNameWithoutExtension(fup.FileName); if (FileName != null) FileName = FileName.Replace(" ", "_"); FileName = FileName + "__" + Common.CreateTemporaryPassword(8) + FileExtension; String AttchFilePath = HttpContext.Current.Server.MapPath(SaveFolder + FileName); File.WriteAllBytes(AttchFilePath, memStream.ToArray()); return FileName; }
public string UploadFile(string filename, UploadFileType fileType, int?timeout = null) { var query = FILTER_STR_HEADER + "*&UploadFileType=" + fileType.ToString(); var path = GenerateGetPath(HttpMethods.POST, query); return(WebClient.UploadFile(path, filename, timeout).ToString()); }
/// <summary> /// /// </summary> /// <param name="filetype"></param> /// <returns></returns> private static string getFileType(UploadFileType filetype) { #region string strfiletype = ""; switch (filetype) { case UploadFileType.doc: strfiletype = "doc"; break; case UploadFileType.jpg: strfiletype = "jpg"; break; case UploadFileType.docx: strfiletype = "docx"; break; case UploadFileType.xls: strfiletype = "xls"; break; case UploadFileType.xlsx: strfiletype = "xlsx"; break; default: break; } return(strfiletype); #endregion }
public UpdaterUC(UploadFileType type) { InitializeComponent(); uploadtype = type; this.btnBrowser.Click += new RoutedEventHandler(btnBrowser_Click); this.btnUpLoad.Click += new RoutedEventHandler(btnUpLoad_Click); this.btnUpdateFiles.Click += new RoutedEventHandler(btnUpdateFiles_Click); }
/// <summary> /// 新增 /// </summary> public override int EntityAdd() { UploadFileTypeRule rule = new UploadFileTypeRule(); UploadFileType entity = EntityGet(); rule.RAdd(entity); return(entity.ID); }
public static UploadFileTypeViewModel AsViewModelModel(UploadFileType model) { return(new UploadFileTypeViewModel() { ID = model.ID, Description = model.Description, FilesPath = model.FilesPath }); }
public InvoiceDocumentViewModel GetAllAspNetUsersImage(string userId, UploadFileType fileType) { List <Expression <Func <InvoiceDocumentMapping, bool> > > filterPredicates = new List <Expression <Func <InvoiceDocumentMapping, bool> > >(); filterPredicates.Add(p => p.UserId == userId); filterPredicates.Add(p => p.FileType == fileType.ToString()); return(EntityToViewModelMapper.MapImage(this.InvoiceDocumentRepository.Find(filterPredicates))); }
/// <summary> /// 存放路径,存放数据库 /// </summary> /// <returns></returns> public static string GetFileUpLoadPath(UploadFileType type = UploadFileType.File) { string dic = type.ToString() + "/"; dic += DateTime.Today.Year + "/"; dic += DateTime.Today.Month + "/"; dic += DateTime.Today.Day + "/"; return(dic); }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { UploadFileType MasterEntity = (UploadFileType)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Enum_UploadFileType("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("Code" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Code) + ","); MasterField.Append("Name" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Name) + ","); MasterField.Append("CLSA" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.CLSA) + ","); MasterField.Append("CLSB" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.CLSB) + ","); MasterField.Append("UploadPicPropID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.UploadPicPropID) + ","); MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("DelFlag" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.DelFlag) + ")"); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } else { AffectedRows = sqlTrans.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBInsert), E); } }
private void RecordVideoStop(GameObject obj) { // liveMainPannel.Recording = false; buttonStartRecord.gameObject.SetActive(true); buttonStopRecord.gameObject.SetActive(false); LiveController.Instance.StopCapture(ref videoOutputPath, ref videoName); Debug.Log("videoOutputPath : " + videoOutputPath + " VideoName : " + videoName); UploadFileType filetype = UploadFileType.Video; StartCoroutine(CheckAndUpload(videoOutputPath, videoName + ".mp4", filetype)); }
async Task <ObservableCollection <UploadInfo> > GetDownloadLinks(UploadFileType uploadFileType) { var response = await FirebaseServiceHelper.Instance.GetUploadInfos(uploadFileType); if (response.Success) { return(response.UploadInfos); } return(new ObservableCollection <UploadInfo>()); }
public void RequestUpdate(UploadFileType uptype) { if (uptype == UploadFileType.ClientPacket) { UpdatePackets(); } else if (uptype == UploadFileType.ServicePacket) { UpdateServices(); } }
public static string GetDirectoryName(this UploadFileType type) { string directory = "error"; var fileTypeDictionary = new Dictionary <int, string> { { 1, "PP" } }; fileTypeDictionary.TryGetValue((int)type, out directory); return(directory); }
private void TakePicture(GameObject obj) { LiveController.Instance.TakeSnap(ref imageOutputPath, ref imageName); if (imageOutputPath == null || imageName == null) { SetStatusErrorText("拍摄照片的保存路径获取失败"); return; } UploadFileType fileType = UploadFileType.Image; StartCoroutine(CheckAndUpload(imageOutputPath, imageName, fileType)); }
private async Task <Document> UploadDocumentOrVersion(Guid projectId, UploadFileType uploadFileType, Stream stream, string contentType, Guid?folderId = null, string nameDocument = null, Guid?documentId = null, UploadTarget target = UploadTarget.Document, UploadAction action = UploadAction.Add) { Dictionary <string, string> queryParams = BuildQueryParamsUploadDoc(projectId, uploadFileType, string.Empty, folderId, nameDocument, documentId, target, action); string docJson = (await Requester.Request(Requester.ApiRootUrl + "uploaddocument", ApiMethod.Post, queryParams, stream, contentType)).Data; return(JsonConvert.DeserializeObject <Document>(docJson)); }
public async Task <IEnumerable <AspNetUsersDocumentViewModel> > GetAspNetUserDocuments() { try { UploadFileType filetype = new UploadFileType(); IEnumerable <AspNetUsersDocumentViewModel> aspNetUserDocuments = await this.AspNetUsersDocumentBusinessLayer.GetAllAspNetUsersDocuments(User.Identity.GetUserId(), UploadFileType.Image); return(aspNetUserDocuments); } catch (Exception ex) { this.ExceptionLogger.Log(LogLevel.Error, ex); throw ex; } }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private UploadFileType EntityGet() { UploadFileType entity = new UploadFileType(); entity.ID = HTDataID; entity.SelectByID(); entity.ID = SysConvert.ToInt32(txtID.Text.Trim()); entity.Code = txtCode.Text.Trim(); entity.Name = txtName.Text.Trim(); entity.CLSA = txtCLSA.Text.Trim(); entity.CLSB = txtCLSB.Text.Trim(); entity.UploadPicPropID = SysConvert.ToInt32(drpUploadPicPropID.EditValue); entity.Remark = txtRemark.Text.Trim(); return(entity); }
private string GetTempDir(UploadFileType uftype) {//临时目录 string tempdir = string.Empty; switch (uftype) { case UploadFileType.ClientPacket: tempdir = PacketsTempFolder; break; case UploadFileType.ServicePacket: tempdir = ServicesTempFolder; break; } return(tempdir); }
/// <summary> /// 修改 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Update(BaseEntity p_Entity) { try { UploadFileType MasterEntity = (UploadFileType)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Enum_UploadFileType SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); UpdateBuilder.Append(" Code=" + SysString.ToDBString(MasterEntity.Code) + ","); UpdateBuilder.Append(" Name=" + SysString.ToDBString(MasterEntity.Name) + ","); UpdateBuilder.Append(" CLSA=" + SysString.ToDBString(MasterEntity.CLSA) + ","); UpdateBuilder.Append(" CLSB=" + SysString.ToDBString(MasterEntity.CLSB) + ","); UpdateBuilder.Append(" UploadPicPropID=" + SysString.ToDBString(MasterEntity.UploadPicPropID) + ","); UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" DelFlag=" + SysString.ToDBString(MasterEntity.DelFlag)); UpdateBuilder.Append(" WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID)); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(UpdateBuilder.ToString()); } else { AffectedRows = sqlTrans.ExecuteNonQuery(UpdateBuilder.ToString()); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBUpdate), E); } }
private static bool CheckFileExt(string fileName, UploadFileType type) { string fileExt = Path.GetExtension(fileName).ToLower(); switch (type) { case UploadFileType.Image: return Array.IndexOf(ImageExts.Split(','), fileExt) != -1; case UploadFileType.Attach: return Array.IndexOf(AttachExts.Split(','), fileExt) != -1; case UploadFileType.Video: return Array.IndexOf(VideoExts.Split(','), fileExt) != -1; default: return false; } }
private static bool CheckFileSize(int fileSize, UploadFileType type) { int limit = 0; switch (type) { case UploadFileType.Image: limit = ImageLimit; break; case UploadFileType.Attach: limit = AttachLimit; break; case UploadFileType.Video: limit = VideoLimit; break; } return limit > fileSize; }
public bool IsSupportedFileType(UploadFileType type) { return type.Equals(UploadFileType.Picture); }
public bool IsSupportedFileType(UploadFileType type) { return !type.Equals(UploadFileType.Invalid); }
private static bool IsValidFileType(string FileExtension, UploadFileType filetype) { if ((filetype & UploadFileType.Pictures) == UploadFileType.Pictures) return new[] { ".JPG", ".GIF", ".PNG", ".BMP" }.Any(o => o == FileExtension.ToUpper()); if ((filetype & UploadFileType.Document) == UploadFileType.Document) return new[] { ".DOC", ".DOCX", ".XLS", ".XLSX" }.Any(o => o == FileExtension.ToUpper()); if ((filetype & UploadFileType.Video) == UploadFileType.Video) return new[] { ".AVI", ".MP4", ".3GP" }.Any(o => o == FileExtension.ToUpper()); if ((filetype & UploadFileType.Sounde) == UploadFileType.Sounde) return new[] { ".MP3", ".WMA" }.Any(o => o == FileExtension.ToUpper()); if ((filetype & UploadFileType.Flash) == UploadFileType.Flash) return new[] { ".SWF", ".FLV" }.Any(o => o == FileExtension.ToUpper()); throw new ArgumentOutOfRangeException("filetype"); }
internal static string GetFileTypes(UploadFileType filetype) { if ((filetype & UploadFileType.Pictures) == UploadFileType.Pictures) return @"fileExtension.toUpperCase().indexOf('.JPG') == -1 && fileExtension.toUpperCase().indexOf('.JPG') == -1 && fileExtension.toUpperCase().indexOf('.GIF') == -1 && fileExtension.toUpperCase().indexOf('.PNG') == -1"; if ((filetype & UploadFileType.Document) == UploadFileType.Document) return @"fileExtension.toUpperCase().indexOf('.DOC') == -1 && fileExtension.toUpperCase().indexOf('.DOCX') == -1 && fileExtension.toUpperCase().indexOf('.XLS') == -1 && fileExtension.toUpperCase().indexOf('.XLSX') == -1"; if ((filetype & UploadFileType.Video) == UploadFileType.Video) return @"fileExtension.toUpperCase().indexOf('.AVI') == -1 && fileExtension.toUpperCase().indexOf('.MP4') == -1 && fileExtension.toUpperCase().indexOf('.3GP') == -1 "; if ((filetype & UploadFileType.Sounde) == UploadFileType.Sounde) return @"fileExtension.toUpperCase().indexOf('.MP3') == -1 && fileExtension.toUpperCase().indexOf('.WMA') == -1 "; if ((filetype & UploadFileType.Flash) == UploadFileType.Flash) return @"fileExtension.toUpperCase().indexOf('.SWF') == -1 && fileExtension.toUpperCase().indexOf('.FLV') == -1 && fileExtension.toUpperCase().indexOf('.WMA') == -1 "; throw new ArgumentOutOfRangeException("filetype"); }