Exemplo n.º 1
0
        /// <summary>
        /// Creates a new file.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>
        ///   <c>PostFilesResponse</c> with a new file id.
        /// </returns>
        public PostFileResponse Post(PostFileRequest request)
        {
            var result =
                fileService.Put(
                    new PutFileRequest
            {
                Data = request.Data,
                User = request.User
            });

            return(new PostFileResponse {
                Data = result.Data
            });
        }
Exemplo n.º 2
0
        public async Task <PostFileResponse> PostFile(PostFileRequest request)
        {
            try
            {
                var postComplete = await _fileService.PostFile(request.FileBase64, request.FileKey);

                return(new PostFileResponse()
                {
                    Success = true
                });
            }
            catch (Exception e)
            {
                return(new PostFileResponse()
                {
                    Success = false,
                    ErrorMessage = e.Message
                });
            }
        }
Exemplo n.º 3
0
        public async Task <T> ExecuteUpload <T>(byte[] contentBytes, string contentName, string fileName)
            where T : VKApiResponse
        {
            PostFileRequest request = await PostFileRequest.Execute(RequestUri, contentBytes, contentName, fileName);

            switch (request.Result)
            {
            case RequestResult.NoNetworkConnection:
                throw new VKApiException("Нет подключения к интернету");

            case RequestResult.Error:
                throw new VKApiException("Не удалось загрузить данные");

            case RequestResult.NoResponse:
                throw new VKApiException("Удаленыый сервер не отвечает");

            case RequestResult.Cancelled:
                throw new VKApiException("Запрос отменен");
            }

            return(JsonConvert.DeserializeObject <T>(request.Response));
        }
 public HttpResponseMessage PostFile(PostFileRequest request)
 {
     try
     {
         if (request.FileType == FileType.JavaScriptLib)
         {
             this.repository.AddLibrary(
                    this.ActiveModule.ModuleID,
                    new JackrabbitLibrary(request.FileType, request.LibraryName, Version.Parse(request.Version), request.Specificity));
             return this.Request.CreateResponse(HttpStatusCode.OK, this.GetAllItems(this.ActiveModule.ModuleID));
         }
         else
         {
             this.repository.AddFile(
                     this.ActiveModule.ModuleID,
                     new JackrabbitFile(request.FileType, request.PathPrefixName, request.FilePath, request.Provider, request.Priority));
             return this.Request.CreateResponse(HttpStatusCode.OK, this.GetAllItems(this.ActiveModule.ModuleID));
         }
     }
     catch (Exception exc)
     {
         return this.HandleException(exc);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new file.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>
        ///   <c>PostFilesResponse</c> with a new file id.
        /// </returns>
        public PostFileResponse Post(PostFileRequest request)
        {
            var result =
                fileService.Put(
                    new PutFileRequest
                    {
                        Data = request.Data,
                        User = request.User
                    });

            return new PostFileResponse { Data = result.Data };
        }