WP Rest API Bild hochladen

Ich versuche, ein Bild über Wordpress REST api v2 hochzuladen. Bisher gelang es mir nur, leere Einträge in der WordPress-Mediathek zu erstellen. Das heißt, sie haben Bildnamen, aber kein tatsächliches Bild.

POST-Anfrage:

http://localhost/wordpress/wp-json/wp/v2/media

Authorization: Basic d29yZHByZXNzOndvcmRwcmVzcw==
Content-Type: application/json
Content-Disposition: attachment;filename=map2.jpg

{
  "source_url" : "file:///C:/Users/x/Desktop/map2.jpg"
}

Antwort

{
  "id": 127,
  "date": "2016-05-25T08:43:30",
  "date_gmt": "2016-05-25T08:43:30",
  "guid": {
    "rendered": "http://localhost/wordpress/wp-content/uploads/2016/05/map2-3.jpg",
    "raw": "http://localhost/wordpress/wp-content/uploads/2016/05/map2-3.jpg"
  },
  "modified": "2016-05-25T08:43:30",
  "modified_gmt": "2016-05-25T08:43:30",
  "password": "",
  "slug": "map2-3",
  "status": "inherit",
  "type": "attachment",
  "link": "http://localhost/wordpress/map2-3/",
  "title": {
    "raw": "map2-3",
    "rendered": "map2-3"
  },
  "author": 1,
  "comment_status": "open",
  "ping_status": "closed",
  "alt_text": "",
  "caption": "",
  "description": "",
  "media_type": "image",
  "mime_type": "image/jpeg",
  "media_details": {},
  "post": null,
  "source_url": "http://localhost/wordpress/wp-content/uploads/2016/05/map2-3.jpg",
  "_links": {
    "self": [
      {
        "href": "http://localhost/wordpress/wp-json/wp/v2/media/127"
      }
    ],
    "collection": [
      {
        "href": "http://localhost/wordpress/wp-json/wp/v2/media"
      }
    ],
    "about": [
      {
        "href": "http://localhost/wordpress/wp-json/wp/v2/types/attachment"
      }
    ],
    "author": [
      {
        "embeddable": true,
        "href": "http://localhost/wordpress/wp-json/wp/v2/users/1"
      }
    ],
    "replies": [
      {
        "embeddable": true,
        "href": "http://localhost/wordpress/wp-json/wp/v2/comments?post=127"
      }
    ]
  }
}

Ich bekomme keine Fehler, alles scheint zu funktionieren, außer der Antwort ->Pos und Antwort -> media_details ist entweder null oder leer. Das Bild selbst wird natürlich nicht hochgeladen.

Basierend aufGitHub WP-API Hinzufügen von Medien Ticket, ich sollte 2 Anfragen senden. ZuerstPOST request sollte Daten mit post object zurückgeben. Ich würde diesen Beitrag Objekt über @ sendPUT Methode und Bild sollten hochgeladen werden ... da ich kein Beitragsobjekt habe, ist dies nicht möglich.

Irgendwelche Ideen was mache ich falsch?

Antworten auf die Frage(6)

Ihre Antwort auf die Frage