Example #1
0
        /// <summary>
        /// Publish a file that will become the new base revision of a previously existing file.  Beware.
        /// </summary>
        /// <param name="ticket">ThreeSixtySharp.Objects.AuthTicket instance for current user.</param>
        /// <param name="project">ThreeSixtySharp.Objects.Project instance to return files from.</param>
        /// <param name="doc_path"></param>
        /// <param name="origin_full_filename"></param>
        /// <param name="document_id">The ThreeSixtySharp.Objects.File.Document_Id parameter of the file to revise.</param>
        /// <param name="tags"></param>
        /// <param name="caption"></param>
        /// <param name="allow_replace"></param>
        /// <returns></returns>
        public ThreeSixtySharp.Objects.File PublishBaseRevision(AuthTicket ticket,
                                                                Project project,
                                                                Document_Path doc_path,
                                                                string origin_full_filename,
                                                                string document_id,
                                                                List <string> tags = null,
                                                                string caption     = null)
        {
            var request = new RestRequest(Method.POST);

            request.Resource = "api/library/publish?replace=1";
            request.AddParameter("ticket", ticket.Ticket);
            request.AddParameter("project_id", project.Project_ID);
            request.AddParameter("directory", doc_path.Path);
            request.AddParameter("filename", System.IO.Path.GetFileName(origin_full_filename));
            request.AddFile("Filedata", origin_full_filename);

            if (tags != null)
            {
                request.AddParameter("tags", string.Join(", ", tags));
            }
            if (caption != null)
            {
                request.AddParameter("caption", caption);
            }

            return(Execute <ThreeSixtySharp.Objects.File>(request));
        }
Example #2
0
        /// <summary>
        /// Asynchronous method to publish a file that will become the new base revision of a previously existing file.  Beware.
        /// </summary>
        /// <param name="ticket">ThreeSixtySharp.Objects.AuthTicket instance for current user.</param>
        /// <param name="project">ThreeSixtySharp.Objects.Project instance to return files from.</param>
        /// <param name="doc_path"></param>
        /// <param name="origin_full_filename"></param>
        /// <param name="document_id">The ThreeSixtySharp.Objects.File.Document_Id parameter of the file to revise.</param>
        /// <param name="tags"></param>
        /// <param name="caption"></param>
        /// <returns></returns>
        public Task <ThreeSixtySharp.Objects.File> PublishBaseRevisionAsync(AuthTicket ticket,
                                                                            Project project,
                                                                            Document_Path doc_path,
                                                                            string origin_full_filename,
                                                                            string document_id,
                                                                            List <string> tags = null,
                                                                            string caption     = null)
        {
            var request = new RestRequest(Method.POST);

            request.Resource = "api/library/publish?replace=1";
            request.AddParameter("ticket", ticket.Ticket);
            request.AddParameter("project_id", project.Project_ID);
            request.AddParameter("directory", doc_path.Path);
            request.AddParameter("filename", System.IO.Path.GetFileName(origin_full_filename));
            using (FileStream fileStream = System.IO.File.OpenRead(origin_full_filename))
            {
                MemoryStream memStream = new MemoryStream();
                memStream.SetLength(fileStream.Length);
                fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length);
                request.AddFile("Filedata", ReadToEnd(fileStream), origin_full_filename);
                if (tags != null)
                {
                    request.AddParameter("tags", string.Join(",", tags));
                }
                if (caption != null)
                {
                    request.AddParameter("caption", caption);
                }

                return(ExecuteAsync <ThreeSixtySharp.Objects.File>(request));
            }
        }
Example #3
0
        /// <summary>
        /// Asynchronous method for returning a list of all ThreeSixtySharp.Objects.File objects for a specified Project,
        /// and optionally for just a specified Document_Path.
        /// </summary>
        /// <param name="ticket">ThreeSixtySharp.Objects.AuthTicket instance for current user.</param>
        /// <param name="project">ThreeSixtySharp.Objects.Project instance to return files from.</param>
        /// <param name="path">Optional ThreeSixtySharp.Objects.Document_Path instance that filters returned File instances
        /// to just those located at the Document_Path.Path location.</param>
        /// <returns>List of ThreeSixtySharp.Object.File instances.</returns>
        public Task <List <ThreeSixtySharp.Objects.File> > GetAllFilesAsync(AuthTicket ticket, Project project, Document_Path path = null)
        {
            var request = new RestRequest(Method.GET);

            request.Resource = "api/library/all_files";
            if (path != null)
            {
                request.AddParameter("directory", path.Path);
            }

            request.AddParameter("ticket", ticket.Ticket);
            request.AddParameter("project_id", project.Project_ID);
            return(ExecuteAsync <List <ThreeSixtySharp.Objects.File> >(request));
        }