add method

Future<Map<String, dynamic>> add({
  1. required String path,
  2. bool? recursive,
  3. bool? progress,
})

Pin objects to local storage. /api/v0/pin/remote/service/add

Arguments:

  • path String: Path to object(s) to be pinned.

Optional arguments:

  • recursive bool: Recursively pin the object linked to by the specified object(s). Default: true.
  • progress bool: Show progress.

Response:

{
  "Pins": [
    "<string>"
  ],
  "Progress": "<int>",
  "StatusCode": "<statusCode>",
  "StatusMessage": "<statusMessage>"
}

See more: https://docs.ipfs.io/reference/http/api/#api-v0-pin-add

Implementation

Future<Map<String, dynamic>> add(
    {required String path, bool? recursive, bool? progress}) async {
  Response? res = await _post(
    Ipfs.dio,
    url: "${Ipfs.url}/pin/add",
    queryParameters: {
      "arg": path,
      if (recursive != null) "recursive": recursive,
      if (progress != null) "progress": progress,
    },
  );

  return _interceptDioResponse(res, expectsResponseBody: true);
}