Esempio n. 1
0
        /// <summary>
        ///     Support for adding attachments through the REST API is added in Redmine 1.4.0.
        ///     Upload a file to server.
        /// </summary>
        /// <param name="data">The content of the file that will be uploaded on server.</param>
        /// <returns>
        ///     Returns the token for uploaded file.
        /// </returns>
        /// <exception cref="RedmineException"></exception>
        /// <exception cref="NotFoundException"></exception>
        /// <exception cref="InternalServerErrorException"></exception>
        /// <exception cref="UnauthorizedException"></exception>
        /// <exception cref="ForbiddenException"></exception>
        /// <exception cref="ConflictException"></exception>
        /// <exception cref="NotAcceptableException"></exception>
        public Upload UploadFile(byte[] data, string fileName)
        {
            var    url = UrlHelper.GetUploadFileUrl(this, fileName);
            Upload u   = WebApiHelper.ExecuteUploadFile(this, url, data, "UploadFile");

            u.FileName = fileName;
            return(u);
        }
Esempio n. 2
0
        /// <summary>
        ///     Support for adding attachments through the REST API is added in Redmine 1.4.0.
        ///     Upload a file to server.
        /// </summary>
        /// <param name="data">The content of the file that will be uploaded on server.</param>
        /// <param name="fileName"></param>
        /// <returns>
        ///     Returns the token for uploaded file.
        /// </returns>
        /// <exception cref="RedmineException"></exception>
        /// <exception cref="NotFoundException"></exception>
        /// <exception cref="InternalServerErrorException"></exception>
        /// <exception cref="UnauthorizedException"></exception>
        /// <exception cref="ForbiddenException"></exception>
        /// <exception cref="ConflictException"></exception>
        /// <exception cref="NotAcceptableException"></exception>
        public Upload UploadFile(byte[] data)
        {
            string url = UrlHelper.GetUploadFileUrl(this);

            return(WebApiHelper.ExecuteUploadFile(this, url, data, "UploadFile"));
        }