0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

misskey apiで画像をアップロードする方法

Posted at

zennのやつと同じです

misskey apiで画像アップロードをするときにはまったのでメモ
なんでどこにも情報がないんでしょうね

結論

結論だけ知りたい人もいると思うので先に書きます。
/api/drive/files/createにfileをmultipart/form-dataでfileを送って
そこで帰ってきたidを使う

で送信して帰ってきた

{
    "id": "a14e42mavoqa001g", //* ここを使う
    "createdAt": "2024-11-28T04:39:52.642Z",
    "name": "レコーディング 2024-11-01 221803.gif",
    "type": "image/gif",
    "md5": "745799dd651cc880bdf4cd799f533e28",
    "size": 400372,
    "isSensitive": false,
    "blurhash": "eL85Zgt7bGf+j[?^t6bFbHj[.ls:aybHj@.Ss:f6a#ja.Soff6f8ja",
    "properties": {
        "width": 2880,
        "height": 1698
    },
    "url": "https://media.misskeyusercontent.jp/io/2fdb7d7a-bc8e-48e8-a56b-f0c9b17d6f93.gif",
    "thumbnailUrl": "https://media.misskeyusercontent.jp/io/thumbnail-03c38e24-9a67-4250-a2c4-5dbc6457ef39.webp",
    "comment": null,
    "folderId": null,
    "folder": null,
    "userId": null,
    "user": null
}

さっき帰ってきたIdを使ってnotes/createにpostするだけ

そうするとこうなる

{
    "createdNote": {
        "id": "a14e68cumipk01z5",
        "createdAt": "2024-11-28T04:41:33.390Z",
        "userId": "9bg3oo1vxg",
        "user": {
            "id": "9bg3oo1vxg",
            "name": "ぽてと:verified_blue:",
            "username": "poteto",
            "host": null,
            "avatarUrl": "https://misskey.io/identicon/poteto@misskey.io",
            "avatarBlurhash": null,
            "avatarDecorations": [],
            "isBot": false,
            "isCat": false,
            "emojis": {},
            "onlineStatus": "online",
            "badgeRoles": []
        },
        "text": "test file upload by api",
        "cw": null,
        "visibility": "public",
        "localOnly": false,
        "reactionAcceptance": null,
        "renoteCount": 0,
        "repliesCount": 0,
        "reactionCount": 0,
        "reactions": {},
        "reactionEmojis": {},
        "fileIds": [
            "a14e42mavoqa001g"
        ],
        "files": [
            {
                "id": "a14e42mavoqa001g",
                "createdAt": "2024-11-28T04:39:52.642Z",
                "name": "レコーディング 2024-11-01 221803.gif",
                "type": "image/gif",
                "md5": "745799dd651cc880bdf4cd799f533e28",
                "size": 400372,
                "isSensitive": false,
                "blurhash": "eL85Zgt7bGf+j[?^t6bFbHj[.ls:aybHj@.Ss:f6a#ja.Soff6f8ja",
                "properties": {
                    "width": 2880,
                    "height": 1698
                },
                "url": "https://media.misskeyusercontent.jp/io/2fdb7d7a-bc8e-48e8-a56b-f0c9b17d6f93.gif",
                "thumbnailUrl": "https://media.misskeyusercontent.jp/io/thumbnail-03c38e24-9a67-4250-a2c4-5dbc6457ef39.webp",
                "comment": null,
                "folderId": null,
                "folder": null,
                "userId": "9bg3oo1vxg",
                "user": null
            }
        ],
        "replyId": null,
        "renoteId": null,
        "clippedCount": 0
    }
}

そうすると

のようになる

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?