Пример #1
0
        /// <summary>
        /// Returns media file's data as stream
        /// </summary>
        /// <param name="key">key of media file</param>
        /// <param name="type">media type: jpeg, png, gif, mp3, mp4, wav</param>
        /// <returns>Media meta object</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 Stream GetData(string key, MediaType type)
        {
            Validate.NotBlank(key, "key cannot be blank");
            string path = MEDIA_ITEM_KEY_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, key).ReplaceFirst(ClientConstants.PLACEHOLDER, ClientUtils.DescriptionAttr(type));

            return(Client.GetFileData(path));
        }
Пример #2
0
        /// <summary>
        /// Returns media file's data as stream, in case there is no appropriate MediaType for your media file pass MediaType.UNKNOWN
        /// </summary>
        /// <param name="id">id of media file</param>
        /// <param name="type">media type: jpeg, png, gif, mp3, mp4, wav</param>
        /// <returns>Media meta object</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 Stream GetData(long id, MediaType type)
        {
            string path = type == MediaType.UNKNOWN ? MEDIA_FILE_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()) :
                          MEDIA_ITEM_ID_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()).ReplaceFirst(ClientConstants.PLACEHOLDER, ClientUtils.DescriptionAttr(type));

            return(Client.GetFileData(path));
        }