添付ファイル

添付ファイル

添付ファイル検索

GET /api/v1/attachments HTTP/1.1

Request

パラメータ 内容 必須 デフォルト値 最大値
q 添付ファイル内を検索する文字列を設定
file_name 検索するファイル名を設定
include_archived アーカイブされたノートも対象にする場合に設定 0
note_code 検索するノートコードを設定
page_code 検索するページコードを設定
order "desc":作成日の降順
"asc":作成日の昇順
desc
page ページ 1
per_page ページ毎の取得数 20 100

パラメータ値例

{
  "q": "検索文字列",
  "include_archived": 1, /* 0, 1 */
  "file_name": "image",
  "note_code": "abcdef",
  "page_code": "aaaaad0001",
  "page": 2,
  "per_page": 50
}

cURLでのリクエスト例

curl 'https://{チームドメイン}.notepm.jp/api/v1/attachments?q=検索文字列&include_archived=1&file_name=image&note_code=abcdef&page_code=aaaaad0001&page=2&per_page=50' \
-H 'Authorization: Bearer {アクセストークン}'

Response

HTTP/1.1 200 OK
{
  "attachments": [
    {
      "file_id": "441dsfbb2-d3s1-44ea-2211-01234d541ds.png",
      "note_code": "abcdef",
      "page_code": "aaaaad0001",
      "comment_number": null,
      "file_name": "image1.png",
      "file_size":132323, /* 132323 byte */
      "download_url": "https://projectmode.notepm.jp/api/v1/attachments/download/441dsfbb2-d3s1-44ea-2211-01234d541ds.png",
      "created_at": "2020-08-01T10:10:10+09:00",
    },
    {
      "file_id": "11e66bd4-d7c7-11ea-9956-080027d541ea.txt",
      "note_code": "abcdef",
      "page_code": "aaaaad0001",
      "comment_number": 1,
      "file_name": "title.text",
      "file_size":132324, /* 132324 byte */
      "download_url": "https://projectmode.notepm.jp/api/v1/attachments/download/11e66bd4-d7c7-11ea-9956-080027d541ea.txt",
      "created_at": "2020-08-01T10:10:10+09:00",
    }
  ],
  "meta": {
    "previous_page": null,
    "next_page": "https://projectmode.notepm.jp/api/v1/attachments?q=検索文字列&include_archived=1&file_name=image&note_code=abcdef&page_code=aaaaad0001&page=2&per_page=50",
    "page": 1,
    "per_page": 50,
    "total": 100
  }
}

添付ファイル登録

POST /api/v1/attachments HTTP/1.1

Request

パラメータ 内容 必須 デフォルト値 最大値
page_code 添付するページコード
comment_number 添付するコメント番号
file[name] 添付するファイル名を設定
file[contents] アップロードするファイル

cURLでのリクエスト例

curl -X POST 'https://{チームドメイン}.notepm.jp/api/v1/attachments' \
-H 'Authorization: Bearer {アクセストークン}' \
-F 'page_code=5e5e085e46' \
-F 'comment_number=1' \
-F 'file[name]=image1.jpg' \
-F 'file[contents]=@/path/to/image1.jpg'

Response

HTTP/1.1 201 created
{
  "attachments":
    {
      "file_id": "441dsfbb2-d3s1-44ea-2211-01234d541ds.png",
      "note_code": "abcdef",
      "page_code": "aaaaad0001",
      "comment_number": 1,
      "file_name": "image1.png",
      "file_size":132323,
      "download_url": "https://projectmode.notepm.jp/api/v1/attachments/download/441dsfbb2-d3s1-44ea-2211-01234d541ds.png",
      "created_at": "2020-08-01T10:10:10+09:00",
    }
}

添付ファイルダウンロード

GET /api/v1/attachments/download/:file_id HTTP/1.1

Request

パラメータなし

cURLでのリクエスト例

curl 'https://{チームドメイン}.notepm.jp/api/v1/attachments/download/{ファイルID}' \
-H 'Authorization: Bearer {アクセストークン}' \
-o {出力先のファイルパス}

Response

HTTP/1.1 200 OK

添付ファイル削除

DELETE /api/v1/attachments/:file_id HTTP/1.1

Request

パラメータなし

cURLでのリクエスト例

curl -X DELETE 'https://{チームドメイン}.notepm.jp/api/v1/attachments/{ファイルID}' \
-H 'Authorization: Bearer {アクセストークン}'

Response

HTTP/1.1 204 No Content