http-put

How do I handle file upload via PUT request in Django?

偶尔善良 提交于 2019-11-28 23:15:20
I'm implementing a REST-style interface and would like to be able to create (via upload) files via a HTTP PUT request. I would like to create either a TemporaryUploadedFile or a InMemoryUploadedFile which I can then pass to my existing FileField and .save() on the object that is part of the model, thereby storing the file. I'm not quite sure about how to handle the file upload part. Specifically, this being a put request, I do not have access to request.FILES since it does not exist in a PUT request. So, some questions: Can I leverage existing functionality in the HttpRequest class,

Content-Type header [application/x-www-form-urlencoded] is not supported on Elasticsearch

时光总嘲笑我的痴心妄想 提交于 2019-11-28 04:48:06
I used to have ElasticSearch 5.2, and just upgraded to 6.0. I am trying to create an index template following guide here , but got error Content-Type header [application/x-www-form-urlencoded] is not supported My query is curl -X PUT localhost:9200/_template/template_1 -d ' { "index_patterns": ["te*", "bar*"], "mappings": { "type1": { "properties": { "host_name": { "type": "keyword" } } } } }' To fix this, add curl option -H 'Content-Type: application/json' This error is due to strict content-type checking introduced in ElasticSearch 6.0, as explained in this post Starting from Elasticsearch 6

Why does this jQuery AJAX PUT work in Chrome but not FF

99封情书 提交于 2019-11-28 03:01:53
问题 In Chrome this does an HTTP PUT just like it should, but in FireFox 21 it doesn't. There are no errors in the javascript console or in the backend. Here is the HTML: <div id="createTeamModal" class="small reveal-modal"> <form id="createTeamForm"> <div class="row"><p id="teamFlavorText" class="lead">Building a new team</p></div> <div class="row"> <div class="small-4 large-4 columns"><label>Team Name:</label></div> <div class="small-6 large-6 columns"><input name="teamName" id="teamName" type=

Hibernate Idempotent Update

随声附和 提交于 2019-11-28 02:16:38
问题 I tried searching this over the net but in vain. Is there a way to use hibernate to perform an idempotent update. One use case is to use HTTP PUT to update a specific field in the database via a REST API. So for example, if I have a database with columns : Id, Name, Phone, UpdateDate and I update the Phone field (of a specific Id ) with the same value multiple times only my first action must update the Phone (and also change my UpdateDate ). Subsequent updates must have no effect on the

How do I handle file upload via PUT request in Django?

痴心易碎 提交于 2019-11-27 14:39:26
问题 I'm implementing a REST-style interface and would like to be able to create (via upload) files via a HTTP PUT request. I would like to create either a TemporaryUploadedFile or a InMemoryUploadedFile which I can then pass to my existing FileField and .save() on the object that is part of the model, thereby storing the file. I'm not quite sure about how to handle the file upload part. Specifically, this being a put request, I do not have access to request.FILES since it does not exist in a PUT

Javascript: Fetch DELETE and PUT requests

时间秒杀一切 提交于 2019-11-27 14:29:12
问题 I have gotten outside of GET and POST methods with Fetch. But I couldn't find any good DELETE and PUT example. So, I ask you for it. Could you give a good example of DELETE and PUT methods with fetch. And explain it a little bit. 回答1: Here is a fetch POST example. You can do the same for DELETE . function createNewProfile(profile) { const formData = new FormData(); formData.append('first_name', profile.firstName); formData.append('last_name', profile.lastName); formData.append('email',

HTTP protocol's PUT and DELETE and their usage in PHP

倖福魔咒の 提交于 2019-11-27 11:01:32
Introduction I've read the following: Hypertext Transfer Protocol (HTTP) is the life of the web. It's used every time you transfer a document, or make an AJAX request. But HTTP is surprisingly a relative unknown among some web developers. The HTTP verbs comprise a major portion of our “uniform interface” constraint and provide us the action counterpart to the noun-based resource. The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT , and DELETE . Huh? Well, we came to the point I lost track of things. PUT and DELETE , they say. I've only

Should I use PATCH or PUT in my REST API?

一曲冷凌霜 提交于 2019-11-27 09:57:46
I want to design my rest endpoint with the appropriate method for the following scenario. There is a group. Each group has a status. The group can be activated or inactivated by the admin. Should I design my end point as PUT /groups/api/v1/groups/{group id}/status/activate OR PATCH /groups/api/v1/groups/{group id} with request body like {action:activate|deactivate} Luke Peterson The PATCH method is the correct choice here as you're updating an existing resource - the group ID. PUT should only be used if you're replacing a resource in its entirety. Further information on partial resource

Using PUT and DELETE methods in Spring MVC

断了今生、忘了曾经 提交于 2019-11-27 07:50:41
I'm trying to use RequestMethod.PUT and RequestMethod.DELETE in Spring MVC controller (version 3.0.2). There are three methods mapped with a URL in the Spring controller class as follows (PUT, GET and POST respectively, for the demonstration purpose only). @RequestMapping(method = {RequestMethod.PUT}, value = {"admin_side/Temp"}, headers = {"content-type=multipart/form-data"}) public String update(@ModelAttribute("tempBean") TempBean tempBean, BindingResult error, Map model, HttpServletRequest request, HttpServletResponse response) { if (ServletFileUpload.isMultipartContent(request)) { System

PHP cURL HTTP PUT

不想你离开。 提交于 2019-11-27 06:47:37
I am trying to create a HTTP PUT request with cURL and I can't make it work. I've read many tutorials but none of them actually worked. Here's my current code: $filedata = array('metadata' => $rdfxml); $ch = curl_init($url); $header = "Content-Type: multipart/form-data; boundary='123456f'"; curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array($header)); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($filedata)); $returned = curl