Skip to content

Commit

Permalink
Update form_submission_pdf_backups.md (#19436)
Browse files Browse the repository at this point in the history
  • Loading branch information
pennja authored Nov 18, 2024
1 parent 3ce75e9 commit b857031
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

This documentation covers the setup and usage of the PDF upload/download solution, designed to handle individual form submissions as PDF files within an AWS S3 bucket.

The following image depicts how this solution is architected:

![Error Remediation Architecture](./error_remediation_architecture.png)

---

## Table of Contents
Expand All @@ -17,6 +13,7 @@ The following image depicts how this solution is architected:
- [Configuration](#configuration)
- [Usage](#usage)
- [Individual Processing](#individual-processing)
- [S3 Pre-Signed URL Retrieval](#s3-pre-signed-url-retrieval)
- [Extending Functionality](#extending-functionality)
- [Overrideable Classes](#overrideable-classes)
- [Directory and File Structure](#directory-and-file-structure)
Expand Down Expand Up @@ -82,20 +79,21 @@ By default, the solution uses the `:benefits_intake_uuid` identifier to query `F

### Individual Processing

To handle a single PDF upload for a form submission, instantiate the `S3Client` directly with the appropriate configuration and submission ID:
To handle a single PDF upload for a form submission, instantiate the `S3Client` directly with the appropriate configuration and submission ID. For backup purposes, specify `type: :submission` during initialization. This ensures that only the original form PDF is uploaded and a presigned URL is generated:

```ruby
config = YourTeamsConfig.new
client = SimpleFormsApi::FormRemediation::S3Client.new(config:, id: <YOUR_SUBMISSION_ID>)
client = SimpleFormsApi::FormRemediation::S3Client.new(config:, id: <YOUR_SUBMISSION_ID>, type: :submission)
client.upload
```

For backup purposes, specify `type: :submission` during initialization. This ensures that only the original form PDF is uploaded and a presigned URL is generated:
### S3 Pre-Signed URL Retrieval

To handle a single PDF download for an already archived form submission, call the `fetch_presigned_url` class method on the `S3Client` class with the appropriate configuration and submission ID:

```ruby
config = YourTeamsConfig.new
client = SimpleFormsApi::FormRemediation::S3Client.new(config:, id: <YOUR_SUBMISSION_ID>, type: :submission)
client.upload
SimpleFormsApi::FormRemediation::S3Client.fetch_presigned_url(<YOUR_SUBMISSION_ID>, config:)
```

---
Expand All @@ -108,10 +106,12 @@ Each component of this solution can be extended or customized to meet team requi
2. Create subclasses for required functionality.
3. Register the subclass in your configuration:

Extending the uploader:

```ruby
# frozen_string_literal: true
require 'simple_forms_api/form_remediation/configuration/base'
require 'simple_forms_api/form_remediation/uploader'
class NewUploader < SimpleFormsApi::FormRemediation::Uploader
def size_range
Expand All @@ -120,6 +120,8 @@ class NewUploader < SimpleFormsApi::FormRemediation::Uploader
end
```

Using the new uploader within your own team's configuration:

```ruby
# frozen_string_literal: true
Expand All @@ -136,6 +138,8 @@ class NewConfig < SimpleFormsApi::FormRemediation::Configuration::Base
end
```

Instantiate the client with your team's configuration:

```ruby
config = NewConfig.new
client = SimpleFormsApi::FormRemediation::S3Client.new(config:, id: <YOUR_SUBMISSION_ID>, type: :submission)
Expand Down

0 comments on commit b857031

Please sign in to comment.