예제 #1
0
        /// <summary>
        /// Upload media file to account
        /// </summary>
        /// <param name="file">file to upload</param>
        /// <param name="name">name for file uploaded</param>
        /// <returns>ResourceId object with sound id</returns>
        /// <exception cref="BadRequestException">          in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception>
        /// <exception cref="UnauthorizedException">        in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception>
        /// <exception cref="AccessForbiddenException">     in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception>
        /// <exception cref="ResourceNotFoundException">    in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception>
        /// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception>
        /// <exception cref="CallfireApiException">         in case HTTP response code is something different from codes listed above.</exception>
        /// <exception cref="CallfireClientException">      in case error has occurred in client.</exception>
        public ResourceId Upload(string pathToFile, string name = null)
        {
            MediaType type = ClientUtils.EnumFromDescription <MediaType>((Path.GetExtension(pathToFile).Replace(".", "")));

            return(Client.PostFile <ResourceId>(MEDIA_PATH, name, pathToFile, ClientUtils.EnumMemberAttr <MediaType>(type)));
        }