Пример #1
0
 public Task <PinFileToIpfsResponse> PinFileToIpfsAsync(Action <CapturedMultipartContent> payloadBuilder, PinataMetadata pinataMetadata = null, PinataOptions pinataOptions = null, CancellationToken cancellationToken = default)
 {
Пример #2
0
        Task <PinJsonToIpfsResponse> IPinningEndpoint.PinJsonToIpfsAsync(string jsonContent, PinataMetadata pinataMetadata = null, PinataOptions pinataOptions = null, CancellationToken cancellationToken = default)
        {
            string body = jsonContent;

            if (pinataOptions is not null || pinataMetadata is not null)
            {
                const string ReplacePattern = "//[[JSON_CONTENT]]//";
                var          payload        = new
                {
                    pinataContent = ReplacePattern,
                    pinataOptions,
                    pinataMetadata
                };
                var payloadJson         = JsonConvert.SerializeObject(payload);
                var indexOfPatternStart = payloadJson.IndexOf(ReplacePattern) - 1;
                var indexOfPatternEnd   = indexOfPatternStart + ReplacePattern.Length + 2;

                var sb        = new StringBuilder();
                var startJson = payloadJson.Substring(0, indexOfPatternStart);
                sb.Append(startJson);
                sb.Append(jsonContent);
                var endJson = payloadJson.Substring(indexOfPatternEnd);
                sb.Append(endJson);
                body = sb.ToString();
            }

            return(this.PinningEndpoint
                   .WithClient(this)
                   .AppendPathSegment("pinJSONToIPFS")
                   .PostAsync(new CapturedJsonContent(body), cancellationToken)
                   .ReceiveJson <PinJsonToIpfsResponse>());
        }
Пример #3
0
 Task <PinJsonToIpfsResponse> IPinningEndpoint.PinJsonToIpfsAsync(object pinataContent, PinataMetadata pinataMetadata = null, PinataOptions pinataOptions = null, CancellationToken cancellationToken = default)
 {
     return(this.PinningEndpoint
            .WithClient(this)
            .AppendPathSegment("pinJSONToIPFS")
            .PostJsonAsync(new
     {
         pinataOptions,
         pinataMetadata,
         pinataContent
     }, cancellationToken)
            .ReceiveJson <PinJsonToIpfsResponse>());
 }