Skip to content

Instantly share code, notes, and snippets.

@tateisu
Created August 16, 2022 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tateisu/1888b77b7453358f2693c4656a30881f to your computer and use it in GitHub Desktop.
Save tateisu/1888b77b7453358f2693c4656a30881f to your computer and use it in GitHub Desktop.
Lemmyへの画像データの投稿

WebUIで画像の追加をすると以下のようなAPIが使われる


request

POST https://lemmy.juggler.jp/pictrs/image
POST /pictrs/image HTTP/2
Host: lemmy.juggler.jp
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0
Accept: */*
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate, br
Referer: https://lemmy.juggler.jp/create_post?community_id=16
Content-Type: multipart/form-data; boundary=---------------------------81315686410589659472095494909
Content-Length: 1046
Origin: https://lemmy.juggler.jp
Connection: keep-alive
Cookie: jwt=****
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
TE: trailers

-----------------------------81315686410589659472095494909
Content-Disposition: form-data; name="images[]"; filename="redcircle.png"
Content-Type: image/png

(binary data)
-----------------------------81315686410589659472095494909--

response

HTTP/2 201 Created
server: nginx
date: Tue, 16 Aug 2022 10:36:58 GMT
content-type: application/json
content-length: 128
strict-transport-security: max-age=63072000
referrer-policy: same-origin
x-content-type-options: nosniff
x-frame-options: DENY
x-xss-protection: 1; mode=block
access-control-allow-origin: *
X-Firefox-Spdy: h2

{
  "msg": "ok",
  "files": [
    {
      "file": "eb6cdbfd-61bc-48c6-a8c1-12cdace4543c.png",
      "delete_token": "cd24f0c8-7942-4cef-a21a-e80414e69e6f"
    }
  ]
}

投稿本文への追加

![](https://lemmy.juggler.jp/pictrs/image/eb6cdbfd-61bc-48c6-a8c1-12cdace4543c.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment