Skip to content

Commit 91b5347

Browse files
Merge pull request #104 from datalogics-dliang/security-optional-delete
PDFCLOUD-5192 Add optional delete step to security samples
2 parents 0b49463 + 56d31d2 commit 91b5347

110 files changed

Lines changed: 2833 additions & 120 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DotNET/Endpoint Examples/JSON Payload/decrypted-pdf.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,34 @@ public static async Task Execute(string[] args)
9393

9494
Console.WriteLine("Processing response received.");
9595
Console.WriteLine(decryptResult);
96+
97+
// All files uploaded or generated are automatically deleted based on the
98+
// File Retention Period as shown on https://pdfrest.com/pricing.
99+
// For immediate deletion of files, particularly when sensitive data
100+
// is involved, an explicit delete call can be made to the API.
101+
//
102+
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.
103+
104+
// Toggle deletion of sensitive files (default: false)
105+
var deleteSensitiveFiles = false;
106+
107+
if (deleteSensitiveFiles)
108+
{
109+
using (var deleteRequest = new HttpRequestMessage(HttpMethod.Post, "delete"))
110+
{
111+
deleteRequest.Headers.TryAddWithoutValidation("Api-Key", apiKey);
112+
deleteRequest.Headers.Accept.Add(new("application/json"));
113+
deleteRequest.Headers.TryAddWithoutValidation("Content-Type", "application/json");
114+
115+
var parsed = JObject.Parse(decryptResult);
116+
var outId = parsed["outputId"].ToString();
117+
JObject deleteJson = new JObject { ["ids"] = $"{uploadedID}, {outId}" };
118+
deleteRequest.Content = new StringContent(deleteJson.ToString(), Encoding.UTF8, "application/json");
119+
var deleteResponse = await httpClient.SendAsync(deleteRequest);
120+
var deleteResult = await deleteResponse.Content.ReadAsStringAsync();
121+
Console.WriteLine(deleteResult);
122+
}
123+
}
96124
}
97125
}
98126
}

DotNET/Endpoint Examples/JSON Payload/encrypted-pdf.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,37 @@ public static async Task Execute(string[] args)
9393

9494
Console.WriteLine("Processing response received.");
9595
Console.WriteLine(encryptResult);
96+
JObject encryptResultJson = JObject.Parse(encryptResult);
97+
var outputID = encryptResultJson["outputId"];
98+
99+
// All files uploaded or generated are automatically deleted based on the
100+
// File Retention Period as shown on https://pdfrest.com/pricing.
101+
// For immediate deletion of files, particularly when sensitive data
102+
// is involved, an explicit delete call can be made to the API.
103+
//
104+
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.
105+
106+
// Toggle deletion of sensitive files (default: false)
107+
var deleteSensitiveFiles = false;
108+
109+
if (deleteSensitiveFiles)
110+
{
111+
using (var deleteRequest = new HttpRequestMessage(HttpMethod.Post, "delete"))
112+
{
113+
deleteRequest.Headers.TryAddWithoutValidation("Api-Key", apiKey);
114+
deleteRequest.Headers.Accept.Add(new("application/json"));
115+
deleteRequest.Headers.TryAddWithoutValidation("Content-Type", "application/json");
116+
117+
JObject deleteJson = new JObject
118+
{
119+
["ids"] = $"{uploadedID}, {outputID}"
120+
};
121+
deleteRequest.Content = new StringContent(deleteJson.ToString(), Encoding.UTF8, "application/json");
122+
var deleteResponse = await httpClient.SendAsync(deleteRequest);
123+
var deleteResult = await deleteResponse.Content.ReadAsStringAsync();
124+
Console.WriteLine(deleteResult);
125+
}
126+
}
96127
}
97128
}
98129
}

DotNET/Endpoint Examples/JSON Payload/pdf-with-redacted-text-applied.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,38 @@ public static async Task Execute(string[] args)
5656
var redactedTextResult = await redactedTextResponse.Content.ReadAsStringAsync();
5757
Console.WriteLine("Processing response received.");
5858
Console.WriteLine(redactedTextResult);
59+
60+
JObject appliedResultJson = JObject.Parse(redactedTextResult);
61+
var outputID = appliedResultJson["outputId"];
62+
63+
// All files uploaded or generated are automatically deleted based on the
64+
// File Retention Period as shown on https://pdfrest.com/pricing.
65+
// For immediate deletion of files, particularly when sensitive data
66+
// is involved, an explicit delete call can be made to the API.
67+
//
68+
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.
69+
70+
// Toggle deletion of sensitive files (default: false)
71+
var deleteSensitiveFiles = false;
72+
73+
if (deleteSensitiveFiles)
74+
{
75+
using (var deleteRequest = new HttpRequestMessage(HttpMethod.Post, "delete"))
76+
{
77+
deleteRequest.Headers.TryAddWithoutValidation("Api-Key", apiKey);
78+
deleteRequest.Headers.Accept.Add(new("application/json"));
79+
deleteRequest.Headers.TryAddWithoutValidation("Content-Type", "application/json");
80+
81+
JObject deleteJson = new JObject
82+
{
83+
["ids"] = $"{uploadedID}, {outputID}"
84+
};
85+
deleteRequest.Content = new StringContent(deleteJson.ToString(), Encoding.UTF8, "application/json");
86+
var deleteResponse = await httpClient.SendAsync(deleteRequest);
87+
var deleteResult = await deleteResponse.Content.ReadAsStringAsync();
88+
Console.WriteLine(deleteResult);
89+
}
90+
}
5991
}
6092
}
6193
}

DotNET/Endpoint Examples/JSON Payload/pdf-with-redacted-text-preview.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,35 @@ public static async Task Execute(string[] args)
6262
var redactedTextResult = await redactedTextResponse.Content.ReadAsStringAsync();
6363
Console.WriteLine("Processing response received.");
6464
Console.WriteLine(redactedTextResult);
65+
66+
// All files uploaded or generated are automatically deleted based on the
67+
// File Retention Period as shown on https://pdfrest.com/pricing.
68+
// For immediate deletion of files, particularly when sensitive data
69+
// is involved, an explicit delete call can be made to the API.
70+
//
71+
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.
72+
// IMPORTANT: Do not delete the previewId (the preview PDF) file until after the redaction is applied
73+
// with the /pdf-with-redacted-text-applied endpoint.
74+
75+
// Toggle deletion of sensitive files (default: false)
76+
var deleteSensitiveFiles = false;
77+
78+
if (deleteSensitiveFiles)
79+
{
80+
using (var deleteRequest = new HttpRequestMessage(HttpMethod.Post, "delete"))
81+
{
82+
deleteRequest.Headers.TryAddWithoutValidation("Api-Key", apiKey);
83+
deleteRequest.Headers.Accept.Add(new("application/json"));
84+
deleteRequest.Headers.TryAddWithoutValidation("Content-Type", "application/json");
85+
86+
var previewId = JObject.Parse(redactedTextResult)["outputId"].ToString();
87+
JObject deleteJson = new JObject { ["ids"] = uploadedID + ", " + previewId };
88+
deleteRequest.Content = new StringContent(deleteJson.ToString(), Encoding.UTF8, "application/json");
89+
var deleteResponse = await httpClient.SendAsync(deleteRequest);
90+
var deleteResult = await deleteResponse.Content.ReadAsStringAsync();
91+
Console.WriteLine(deleteResult);
92+
}
93+
}
6594
}
6695
}
6796
}

DotNET/Endpoint Examples/JSON Payload/restricted-pdf.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,37 @@ public static async Task Execute(string[] args)
9494

9595
Console.WriteLine("Processing response received.");
9696
Console.WriteLine(restrictResult);
97+
JObject restrictResultJson = JObject.Parse(restrictResult);
98+
var outputID = restrictResultJson["outputId"];
99+
100+
// All files uploaded or generated are automatically deleted based on the
101+
// File Retention Period as shown on https://pdfrest.com/pricing.
102+
// For immediate deletion of files, particularly when sensitive data
103+
// is involved, an explicit delete call can be made to the API.
104+
//
105+
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.
106+
107+
// Toggle deletion of sensitive files (default: false)
108+
var deleteSensitiveFiles = false;
109+
110+
if (deleteSensitiveFiles)
111+
{
112+
using (var deleteRequest = new HttpRequestMessage(HttpMethod.Post, "delete"))
113+
{
114+
deleteRequest.Headers.TryAddWithoutValidation("Api-Key", apiKey);
115+
deleteRequest.Headers.Accept.Add(new("application/json"));
116+
deleteRequest.Headers.TryAddWithoutValidation("Content-Type", "application/json");
117+
118+
JObject deleteJson = new JObject
119+
{
120+
["ids"] = $"{uploadedID}, {outputID}"
121+
};
122+
deleteRequest.Content = new StringContent(deleteJson.ToString(), Encoding.UTF8, "application/json");
123+
var deleteResponse = await httpClient.SendAsync(deleteRequest);
124+
var deleteResult = await deleteResponse.Content.ReadAsStringAsync();
125+
Console.WriteLine(deleteResult);
126+
}
127+
}
97128
}
98129
}
99130
}

DotNET/Endpoint Examples/JSON Payload/unrestricted-pdf.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,34 @@ public static async Task Execute(string[] args)
9393

9494
Console.WriteLine("Processing response received.");
9595
Console.WriteLine(unrestrictResult);
96+
97+
// All files uploaded or generated are automatically deleted based on the
98+
// File Retention Period as shown on https://pdfrest.com/pricing.
99+
// For immediate deletion of files, particularly when sensitive data
100+
// is involved, an explicit delete call can be made to the API.
101+
//
102+
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.
103+
104+
// Toggle deletion of sensitive files (default: false)
105+
var deleteSensitiveFiles = false;
106+
107+
if (deleteSensitiveFiles)
108+
{
109+
using (var deleteRequest = new HttpRequestMessage(HttpMethod.Post, "delete"))
110+
{
111+
deleteRequest.Headers.TryAddWithoutValidation("Api-Key", apiKey);
112+
deleteRequest.Headers.Accept.Add(new("application/json"));
113+
deleteRequest.Headers.TryAddWithoutValidation("Content-Type", "application/json");
114+
115+
var parsed = JObject.Parse(unrestrictResult);
116+
var outId = parsed["outputId"].ToString();
117+
JObject deleteJson = new JObject { ["ids"] = $"{uploadedID}, {outId}" };
118+
deleteRequest.Content = new StringContent(deleteJson.ToString(), Encoding.UTF8, "application/json");
119+
var deleteResponse = await httpClient.SendAsync(deleteRequest);
120+
var deleteResult = await deleteResponse.Content.ReadAsStringAsync();
121+
Console.WriteLine(deleteResult);
122+
}
123+
}
96124
}
97125
}
98126
}

DotNET/Endpoint Examples/JSON Payload/watermarked-pdf.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,37 @@ public static async Task Execute(string[] args)
5656
var watermarkResult = await watermarkResponse.Content.ReadAsStringAsync();
5757
Console.WriteLine("Processing response received.");
5858
Console.WriteLine(watermarkResult);
59+
JObject watermarkResultJson = JObject.Parse(watermarkResult);
60+
var outputID = watermarkResultJson["outputId"];
61+
62+
// All files uploaded or generated are automatically deleted based on the
63+
// File Retention Period as shown on https://pdfrest.com/pricing.
64+
// For immediate deletion of files, particularly when sensitive data
65+
// is involved, an explicit delete call can be made to the API.
66+
//
67+
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.
68+
69+
// Toggle deletion of sensitive files (default: false)
70+
var deleteSensitiveFiles = false;
71+
72+
if (deleteSensitiveFiles)
73+
{
74+
using (var deleteRequest = new HttpRequestMessage(HttpMethod.Post, "delete"))
75+
{
76+
deleteRequest.Headers.TryAddWithoutValidation("Api-Key", apiKey);
77+
deleteRequest.Headers.Accept.Add(new("application/json"));
78+
deleteRequest.Headers.TryAddWithoutValidation("Content-Type", "application/json");
79+
80+
JObject deleteJson = new JObject
81+
{
82+
["ids"] = $"{uploadedID}, {outputID}"
83+
};
84+
deleteRequest.Content = new StringContent(deleteJson.ToString(), Encoding.UTF8, "application/json");
85+
var deleteResponse = await httpClient.SendAsync(deleteRequest);
86+
var deleteResult = await deleteResponse.Content.ReadAsStringAsync();
87+
Console.WriteLine(deleteResult);
88+
}
89+
}
5990
}
6091
}
6192
}

DotNET/Endpoint Examples/Multipart Payload/decrypted-pdf.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
using System.Text;
2121

22+
23+
2224
namespace Samples.EndpointExamples.MultipartPayload
2325
{
2426
public static class DecryptedPdf
@@ -69,6 +71,35 @@ public static async Task Execute(string[] args)
6971

7072
Console.WriteLine("API response received.");
7173
Console.WriteLine(apiResult);
74+
75+
// All files uploaded or generated are automatically deleted based on the
76+
// File Retention Period as shown on https://pdfrest.com/pricing.
77+
// For immediate deletion of files, particularly when sensitive data
78+
// is involved, an explicit delete call can be made to the API.
79+
//
80+
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.
81+
82+
// Toggle deletion of sensitive files (default: false)
83+
var deleteSensitiveFiles = false;
84+
85+
if (deleteSensitiveFiles)
86+
{
87+
using (var deleteRequest = new HttpRequestMessage(HttpMethod.Post, "delete"))
88+
{
89+
deleteRequest.Headers.TryAddWithoutValidation("Api-Key", apiKey);
90+
deleteRequest.Headers.Accept.Add(new("application/json"));
91+
deleteRequest.Headers.TryAddWithoutValidation("Content-Type", "application/json");
92+
93+
var parsed = Newtonsoft.Json.Linq.JObject.Parse(apiResult);
94+
var inId = parsed["inputId"].ToString();
95+
var outId = parsed["outputId"].ToString();
96+
var deleteJson = new Newtonsoft.Json.Linq.JObject { ["ids"] = $"{inId}, {outId}" };
97+
deleteRequest.Content = new StringContent(deleteJson.ToString(), Encoding.UTF8, "application/json");
98+
var deleteResponse = await httpClient.SendAsync(deleteRequest);
99+
var deleteResult = await deleteResponse.Content.ReadAsStringAsync();
100+
Console.WriteLine(deleteResult);
101+
}
102+
}
72103
}
73104
}
74105
}

DotNET/Endpoint Examples/Multipart Payload/encrypted-pdf.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
using System.Text;
2121

22+
23+
2224
namespace Samples.EndpointExamples.MultipartPayload
2325
{
2426
public static class EncryptedPdf
@@ -69,6 +71,35 @@ public static async Task Execute(string[] args)
6971

7072
Console.WriteLine("API response received.");
7173
Console.WriteLine(apiResult);
74+
75+
// All files uploaded or generated are automatically deleted based on the
76+
// File Retention Period as shown on https://pdfrest.com/pricing.
77+
// For immediate deletion of files, particularly when sensitive data
78+
// is involved, an explicit delete call can be made to the API.
79+
//
80+
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.
81+
82+
// Toggle deletion of sensitive files (default: false)
83+
var deleteSensitiveFiles = false;
84+
85+
if (deleteSensitiveFiles)
86+
{
87+
using (var deleteRequest = new HttpRequestMessage(HttpMethod.Post, "delete"))
88+
{
89+
deleteRequest.Headers.TryAddWithoutValidation("Api-Key", apiKey);
90+
deleteRequest.Headers.Accept.Add(new("application/json"));
91+
deleteRequest.Headers.TryAddWithoutValidation("Content-Type", "application/json");
92+
93+
var parsed = Newtonsoft.Json.Linq.JObject.Parse(apiResult);
94+
var inId = parsed["inputId"].ToString();
95+
var outId = parsed["outputId"].ToString();
96+
var deleteJson = new Newtonsoft.Json.Linq.JObject { ["ids"] = $"{inId}, {outId}" };
97+
deleteRequest.Content = new StringContent(deleteJson.ToString(), Encoding.UTF8, "application/json");
98+
var deleteResponse = await httpClient.SendAsync(deleteRequest);
99+
var deleteResult = await deleteResponse.Content.ReadAsStringAsync();
100+
Console.WriteLine(deleteResult);
101+
}
102+
}
72103
}
73104
}
74105
}

0 commit comments

Comments
 (0)