{"id":55,"date":"2025-08-30T02:14:24","date_gmt":"2025-08-29T18:14:24","guid":{"rendered":"https:\/\/blog.imgbed.cn\/?p=55"},"modified":"2025-12-07T14:37:23","modified_gmt":"2025-12-07T06:37:23","slug":"%e5%9b%be%e5%ba%8a%e5%b0%8f%e9%95%87-api-%e6%96%87%e6%a1%a3","status":"publish","type":"post","link":"https:\/\/blog.imgbed.cn\/index.php\/2025\/08\/30\/%e5%9b%be%e5%ba%8a%e5%b0%8f%e9%95%87-api-%e6%96%87%e6%a1%a3\/","title":{"rendered":"\u56fe\u5e8a\u5c0f\u9547 API \u6587\u6863"},"content":{"rendered":"<h1>\u4f7f\u7528\u524d\u63d0<\/h1>\n<ol>\n<li>\u4ed8\u8d39\u4f1a\u5458\uff08\u5e74\u8d39\u4f1a\u5458\uff09<\/li>\n<li>\u7ba1\u7406\u5458\u63d0\u4f9b token \uff08\u767b\u5f55\u56fe\u5e8a imgbed.cn \u540e\u70b9\u51fb\u90ae\u7bb1-\u67e5\u770b token\uff0c\u6216\u4ed8\u8d39\u540e\u8054\u7cfb\u7ad9\u957f\u83b7\u53d6\uff09<\/li>\n<li>IP \u62a5\u5907\uff08\u6216\u57df\u540d\u62a5\u5907\uff09<\/li>\n<\/ol>\n<blockquote>\n<p>\u540e\u7aef\u8c03\u7528\u5219\u8fdb\u884c ip \u62a5\u5907\uff0c\u524d\u7aef\u8c03\u7528\u5219\u8fdb\u884c\u57df\u540d\u62a5\u5907\u3002<\/p>\n<\/blockquote>\n<h1>\u9650\u5236<\/h1>\n<p>QPS\uff1a1 \uff0c\u6bcf\u5929\u4e0a\u9650 1000\u3002\u6bcf\u6708\u4e0a\u4f20\u5bb9\u91cf 1G\u3002<\/p>\n<p><strong>\n<u><font style=\"color:#DF2A3F;background-color:#81DFE4\">\u5982\u9700\u8c03\u6574\u52a1\u5fc5\u8054\u7cfb\u535a\u4e3b!<\/font><\/u><\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.51shazhu.com\/autoupload\/fdd\/default\/yuque\/0\/2025\/png\/420230\/1749366242756-92247c27-97a2-4832-86fa-f7d455df719f.png\/webp\" alt=\"\u56fe\u5e8a\u5c0f\u9547\" \/><\/p>\n<h1>\u63a5\u53e3<\/h1>\n<h2>\u4e0a\u4f20\u63a5\u53e3<\/h2>\n<p>\u5730\u5740\uff1a<a href=\"https:\/\/playground.z.wiki\/img\/api\/upload\">https:\/\/playground.z.wiki\/img\/api\/upload<\/a><\/p>\n<p>\u4e0a\u4f20\u793a\u4f8b<\/p>\n<pre><code class=\"lang-java language-java java\">import okhttp3.*;\n\nimport java.io.File;\nimport java.io.IOException;\n\npublic class UploadWithOkHttp {\n    public static void main(String[] args) throws IOException {\n        OkHttpClient client = new OkHttpClient();\n\n        File file = new File(&quot;path\/to\/your\/image.jpg&quot;);\n\n        RequestBody requestBody = new MultipartBody.Builder()\n            .setType(MultipartBody.FORM)\n            .addFormDataPart(&quot;file&quot;, file.getName(),\n                RequestBody.create(file, MediaType.parse(&quot;image\/jpeg&quot;)))\n            .addFormDataPart(&quot;fileName&quot;, &quot;custom_name.jpg&quot;)\n            .addFormDataPart(&quot;uid&quot;, &quot;${token}&quot;)\n            .build();\n\n        Request request = new Request.Builder()\n            .url(&quot;https:\/\/playground.z.wiki\/img\/api\/upload&quot;)\n            .post(requestBody)\n            .build();\n\n        try (Response response = client.newCall(request).execute()) {\n            System.out.println(&quot;Response code: &quot; + response.code());\n            System.out.println(&quot;Body: &quot; + response.body().string());\n        }\n    }\n}<\/code><\/pre>\n<p>\u5176\u4ed6\u53c2\u6570<\/p>\n<table>\n<thead>\n<tr>\n<th><strong><font style=\"color:#FFFFFF\">\u53c2\u6570<\/font><\/strong><\/th>\n<th><strong><font style=\"color:#FFFFFF\">\u542b\u4e49<\/font><\/strong><\/th>\n<th><strong><font style=\"color:#FFFFFF\">\u5907\u6ce8<\/font><\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>dir<\/td>\n<td>\u76ee\u5f55<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>randomPath<\/td>\n<td>\u662f\u5426\u968f\u673a\u8def\u5f84<\/td>\n<td>true \u6216 false<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7 <code>.addFormDataPart(&quot;name&quot;, &quot;value&quot;)<\/code>\u8fdb\u884c\u4f20\u9012\u3002<\/p>\n<h2>\u5220\u9664\u63a5\u53e3<\/h2>\n<p>\u5730\u5740\uff1a<a href=\"https:\/\/playground.z.wiki\/img\/delete?uid=${token}&amp;id=${id\">https:\/\/playground.z.wiki\/img\/delete?uid=${token}&amp;id=${id<\/a>}<\/p>\n<p>method: <strong>\n<u>delete<\/u><\/strong><\/p>\n<p>\u6ce8\uff1atoken \u4e3a\u7ba1\u7406\u5458\u63d0\u4f9b\u7684 token\uff0cid \u4e3a\u4e0a\u4f20\u8bb0\u5f55\u7684 id\uff08\u4e0a\u4f20\u540e\u4f1a\u8fd4\u56de\u8be5 id\uff09<\/p>\n<pre><code class=\"lang-java language-java java\">curl &#039;https:\/\/playground.z.wiki\/img\/delete?id=${id}&amp;uid=${token}&#039; -X &#039;DELETE&#039;<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u524d\u63d0 \u4ed8\u8d39\u4f1a\u5458\uff08\u5e74\u8d39\u4f1a\u5458\uff09&hellip;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-55","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.imgbed.cn\/index.php\/wp-json\/wp\/v2\/posts\/55","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.imgbed.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.imgbed.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.imgbed.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.imgbed.cn\/index.php\/wp-json\/wp\/v2\/comments?post=55"}],"version-history":[{"count":2,"href":"https:\/\/blog.imgbed.cn\/index.php\/wp-json\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":107,"href":"https:\/\/blog.imgbed.cn\/index.php\/wp-json\/wp\/v2\/posts\/55\/revisions\/107"}],"wp:attachment":[{"href":"https:\/\/blog.imgbed.cn\/index.php\/wp-json\/wp\/v2\/media?parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.imgbed.cn\/index.php\/wp-json\/wp\/v2\/categories?post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.imgbed.cn\/index.php\/wp-json\/wp\/v2\/tags?post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}