/// <summary> /// Upload Video api call /// </summary> /// <param name="url"> upload url created by CreateVideoUploadUrl() method</param> /// <param name="filePath"> physical file path of the video</param> /// <returns></returns> public VideoUploadResponse UploadVideo(string filePath) { VideoUploadResponse response = new VideoUploadResponse(); response.Status = CallExecutionStatus.Error; try { //create upload url UploadUrl url = CreateVideoUploadUrl(); //format upload url string upload_url = url.Link.Protocol + "://" + url.Link.Address + url.Link.Path; string uploadResponse = ""; //create request query strings parameters NameValueCollection nvc = new NameValueCollection(); nvc.Add("key", url.Link.Query.Key); nvc.Add("token", url.Link.Query.Token); uploadResponse = Upload(upload_url, nvc, filePath); //deserialize response to VideoUploadResponse response = JsonConvert.DeserializeObject <VideoUploadResponse>(uploadResponse); //set api call result response.ErrorMessage = ""; response.Status = CallExecutionStatus.OK; } catch (Exception ex) { response.Status = CallExecutionStatus.Error; response.ErrorMessage = ex.Message + Environment.NewLine + ex.StackTrace; } return(response); }
public async Task RetrieveUploadUrlAsyncTest() { var returnValue = new UploadUrl(); this.uploadUrlData.Setup(mockItem => mockItem.RetrieveUploadUrlAsync()).Returns(Task.FromResult(returnValue)); var uploadUrl = await this.uploadUrlsManager.RetrieveUploadUrlAsync(); Assert.AreSame(returnValue, uploadUrl); }
/// <summary> /// create video upload url /// </summary> /// <returns>UploadUrl <media><key>video key</key></media></returns> private UploadUrl CreateVideoUploadUrl() { UploadUrl response = new UploadUrl(); string responseJson = Call("/videos/create"); response = JsonConvert.DeserializeObject <UploadUrl>(responseJson); return(response); }
public async Task <IActionResult> Get(Guid sessionId) { try { var sessionContext = await _sessionManagementService.GetSessionContext(sessionId); var templateDescriptor = sessionContext.TemplateDescriptor; var uploadUrls = UploadUrl.Generate( templateDescriptor, templateCode => Url.Action( nameof(UploadFile), new { sessionId, templateCode })); var fetchUrls = FetchUrl.Generate( templateDescriptor, templateCode => Url.Action( nameof(FetchFile), new { sessionId, templateCode })); Response.Headers[HeaderNames.ETag] = $"\"{sessionId}\""; Response.Headers[HeaderNames.Expires] = sessionContext.ExpiresAt.ToString("R"); return(Json( new { sessionContext.AuthorInfo.Author, sessionContext.AuthorInfo.AuthorLogin, sessionContext.AuthorInfo.AuthorName, sessionContext.Language, Template = new { Id = sessionContext.TemplateId, templateDescriptor.VersionId, templateDescriptor.LastModified, templateDescriptor.Author, templateDescriptor.AuthorLogin, templateDescriptor.AuthorName, templateDescriptor.Properties, templateDescriptor.Elements }, uploadUrls, fetchUrls })); } catch (ObjectNotFoundException ex) { return(NotFound(ex.Message)); } catch (SessionExpiredException ex) { return(Gone(ex.ExpiredAt)); } }
public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = "label"; output.Content.Clear(); string id = "fapfile"; if (Id.IsPresent()) { id = $"file-{Id}"; } FileInput file = new FileInput(id); if (ShowCaption) { file.SetShowCaption(ShowCaption); } if (FileExtensions.IsPresent()) { string[] exts = FileExtensions.Split(','); List <string> list = new List <string>(); foreach (var item in exts) { list.Add(item); } file.SetAllowedFileExtensions(list.ToJson()); } if (UploadUrl.IsPresent()) { file.SetUploadUrl(UploadUrl); } if (MaxFilecount > 0) { file.SetMaxFileCount(MaxFilecount); } if (MaxFilesize > 0) { file.SetMaxFileSize(MaxFilesize); } if (OverwriteInitial) { file.SetOverwriteInitial(OverwriteInitial); } if (ExtraData.IsPresent()) { file.SetUploadExtraData(ExtraData); } if (AutoUpload) { file.AutoUpload = AutoUpload; } output.Content.AppendHtml(file.ToString()); }
public virtual void WriteTo(XElement xE) { XElement xItem = null; if (Id != null) { xItem = new XElement(XName.Get("id", "https://adwords.google.com/api/adwords/cm/v201609")); xItem.Add(Id.Value.ToString()); xE.Add(xItem); } if (Status != null) { xItem = new XElement(XName.Get("status", "https://adwords.google.com/api/adwords/cm/v201609")); xItem.Add(Status.Value.ToXmlValue()); xE.Add(xItem); } if (ProgressStats != null) { xItem = new XElement(XName.Get("progressStats", "https://adwords.google.com/api/adwords/cm/v201609")); ProgressStats.WriteTo(xItem); xE.Add(xItem); } if (UploadUrl != null) { xItem = new XElement(XName.Get("uploadUrl", "https://adwords.google.com/api/adwords/cm/v201609")); UploadUrl.WriteTo(xItem); xE.Add(xItem); } if (DownloadUrl != null) { xItem = new XElement(XName.Get("downloadUrl", "https://adwords.google.com/api/adwords/cm/v201609")); DownloadUrl.WriteTo(xItem); xE.Add(xItem); } if (ProcessingErrors != null) { foreach (var processingErrorsItem in ProcessingErrors) { xItem = new XElement(XName.Get("processingErrors", "https://adwords.google.com/api/adwords/cm/v201609")); processingErrorsItem.WriteTo(xItem); xE.Add(xItem); } } if (DiskUsageQuotaBalance != null) { xItem = new XElement(XName.Get("diskUsageQuotaBalance", "https://adwords.google.com/api/adwords/cm/v201609")); xItem.Add(DiskUsageQuotaBalance.Value.ToString()); xE.Add(xItem); } }
public override int GetHashCode() { int hash = 1; if (videoId_ != null) { hash ^= VideoId.GetHashCode(); } if (UploadUrl.Length != 0) { hash ^= UploadUrl.GetHashCode(); } if (timestamp_ != null) { hash ^= Timestamp.GetHashCode(); } return(hash); }
public Schema() : base() { InstanceType = typeof(__FileUplo__); ClassName = "FileUploadPage"; Properties.ClearExposed(); Html = Add <__TString__>("Html"); Html.DefaultValue = "/KitchenSink/FileUploadPage.html"; Html.SetCustomAccessors((_p_) => { return(((__FileUplo__)_p_).__bf__Html__); }, (_p_, _v_) => { ((__FileUplo__)_p_).__bf__Html__ = (System.String)_v_; }, false); SessionId = Add <__TString__>("SessionId"); SessionId.DefaultValue = ""; SessionId.SetCustomAccessors((_p_) => { return(((__FileUplo__)_p_).__bf__SessionId__); }, (_p_, _v_) => { ((__FileUplo__)_p_).__bf__SessionId__ = (System.String)_v_; }, false); UploadUrl = Add <__TString__>("UploadUrl"); UploadUrl.DefaultValue = "/KitchenSink/fileupload/upload"; UploadUrl.SetCustomAccessors((_p_) => { return(((__FileUplo__)_p_).__bf__UploadUrl__); }, (_p_, _v_) => { ((__FileUplo__)_p_).__bf__UploadUrl__ = (System.String)_v_; }, false); Files = Add <__TArray__>("Files"); Files.SetCustomGetElementType((arr) => { return(__FiFileUplo__.DefaultTemplate); }); Files.SetCustomAccessors((_p_) => { return(((__FileUplo__)_p_).__bf__Files__); }, (_p_, _v_) => { ((__FileUplo__)_p_).__bf__Files__ = (__Arr__)_v_; }, false); Tasks = Add <__TArray1__>("Tasks"); Tasks.SetCustomGetElementType((arr) => { return(__FiFileUplo3__.DefaultTemplate); }); Tasks.SetCustomAccessors((_p_) => { return(((__FileUplo__)_p_).__bf__Tasks__); }, (_p_, _v_) => { ((__FileUplo__)_p_).__bf__Tasks__ = (__Arr1__)_v_; }, false); }
protected override Dictionary <string, object> OptionsJSInternal() { var result = base.OptionsJSInternal(); result.Add("asyncUpload", AsyncUpload); if (UploadUrl.HasText()) { result.Add("uploadUrl", UploadUrl); } if (UploadDroppedUrl.HasText()) { result.Add("uploadDroppedUrl", UploadDroppedUrl); } if (!DragAndDrop) { result.Add("dragAndDrop", false); } result.Add("download", (int)Download); if (typeof(IFilePath).IsAssignableFrom(this.Type.CleanType()) && !this.ReadOnly) { if (FileType == null) { throw new ArgumentException("FileType is mandatory for FilePathEntity (FileLine {0})".FormatWith(Prefix)); } result.Add("fileType", FileType.Key); if (this.CalculatedDirectory.HasText()) { result.Add("calculatedDirectory", this.CalculatedDirectory); } } return(result); }
/// <summary> /// Adds the visitor. /// </summary> /// <returns> /// Add Visitor View /// </returns> public async Task<ActionResult> AddVisitor() { var visitorPresenter = new VisitorPresenter(); BaseController.GetAboutUsInformation(visitorPresenter); visitorPresenter = InsertDummyPersonalData(visitorPresenter); var saveUtcNow = BaseController.GenerateLocalDateTime(DateTime.UtcNow); ViewBag.dob = saveUtcNow.ToString(ShortDateTimeFormat, CultureInfo.InvariantCulture); ViewBag.startDate = saveUtcNow.ToString(this.ApplicationSettings.DateFormat, CultureInfo.InvariantCulture); ViewBag.expireDate = saveUtcNow.AddHours(1).ToString(this.ApplicationSettings.DateFormat, CultureInfo.InvariantCulture); if (SessionData.Instance.MasterData != null && SessionData.Instance.MasterData.Ship != null && !string.IsNullOrEmpty(SessionData.Instance.MasterData.Ship.Name)) { visitorPresenter.ShipName = SessionData.Instance.MasterData.Ship.Name; } securityPhotoUploadAddress = await this.visitorManager.RetrieveVisitorUploadUrlAsync(); return this.View(visitorPresenter); }
/// <summary> /// Indexes this instance. /// </summary> /// <param name="status">The status.</param> /// <returns> /// The view /// </returns> public async Task<ActionResult> Index(string status) { var presenter = new VisitorPresenter(); BaseController.GetAboutUsInformation(presenter); var shipTime = BaseController.GenerateLocalDateTime(DateTime.UtcNow); var searchFilter = new SearchFilters(); searchFilter.ShipTime = shipTime.ToString(CultureInfo.InvariantCulture); searchFilter.PageNumber = 1; if (!string.IsNullOrWhiteSpace(status)) { ViewBag.VisitorStatus = status; SessionData.Instance.VisitorStatus = status; if (status.Equals(OnboardVisitorStatus)) { searchFilter.Status = true; searchFilter.MaxResult = int.MaxValue; } else if (status.Equals(OffboardVisitorStatus)) { searchFilter.Status = false; searchFilter.MaxResult = int.MaxValue; } else { searchFilter.MaxResult = this.ApplicationSettings.MaxPageSize; } } else { ViewBag.VisitorStatus = ExpectedVisitorStatus; SessionData.Instance.VisitorStatus = ExpectedVisitorStatus; searchFilter.MaxResult = this.ApplicationSettings.MaxPageSize; } var todaysVisitors = await this.visitorManager.GetVisitorsAsync(searchFilter); if (todaysVisitors != null) { SessionData.Instance.VisitorItemListResult.Items.Clear(); SessionData.Instance.AssignVisitorSearchResult(todaysVisitors); this.ExtractOnLoadPagedRecords(presenter); } securityPhotoUploadAddress = await this.visitorManager.RetrieveVisitorUploadUrlAsync(); presenter = InsertDummyPersonalData(presenter); return this.View(presenter); }