Aliasing a File with the HTTP Proxy

When aliasing an entire file, such as an image, the standard reveal operation on the dashboard will not work. Because the aliased payload itself is a file, and not a part of one like a .json or .html file, the standard Redact/Reveal operations on the dashboard do not apply. This article will walk you through the process of how to Redact an entire file into an alias. 

The first Steps are going to be the same regardless of the method used to send the file:

  1. Go to the dashboard, and go to your Routes. Either create a new route for a new upstream, or click on the existing route.
  2. Add a filter. You only need to specify the conditions for pathinfo, Content-type and HTTP Method. 
  3. Export your configuration as a YAML file. 
  4. Open the YAML in the text editor of your choice. Under data.attributes.entries, there is a list of each of your filters, and the default one should look something like this:
            - classifiers: {}
                condition: AND
                  - condition: null
                      field: PathInfo
                      operator: matches
                      type: string
                        - /post
                  - condition: null
                      field: ContentType
                      operator: equals
                      type: string
                        - application/json
              id: 6296518e-2041-4a6b-8744-2b1fdb59b472
              id_selector: null
              operation: REDACT
              operations: null
              phase: REQUEST
              public_token_generator: UUID
                - body
              token_manager: PERSISTENT
              transformer: JSON_PATH
                - $.account_number
              transformer_config_map: null
              type: null

Here, we can see that operations:null. We will replace null with an array of operations. The operations used will depend on the content-type of the request. 

Sending a file via multipart/form-data

If you are sending data via multipart/form-data, we need to use the two operations ProcessMultipartOperationConfig and RedactFileOperationConfig. We can insert them in place of the null like so:

          operations: |-
[ {
              "@type" : "",
              "partNames" : [ "file1", "file2", "file3" ]
            }, {
              "@type" : ""
            } ]

The ProcessMultipartOperationConfig operation also contains partNames, an array of HTML file name attributes to expect. A simple input tag for a form to submit the image in looks like this:

 <input id="uploadFile" name="file1" type="file"></input>

The name attribute of the input tag of the file that needs to be aliased must be in the partNames attribute of the operation.

Once this is inserted in place of the null operation in the YAML you downloaded, save the YAML file. Then, go back to your Routes page, click on Manage, and import the YAML file you just saved. 


With this configuration uploaded, you are able to alias files directly. Below you can see how our echo server responds when you send a file via multipart/form-data without redacting, and how it responds when the operation is applied:

File with no redaction:


The redacted file is now a VGS Alias:


Sending a file as application/x-www-form-urlencoded

If you are sending a file as x-www-form-urlencoded, then the two operations you need to use are ProcessHttpBodyOperationConfig and RedactFileOperationConfig. We can insert those operations in place of the null like so:

          operations: |-
{ "@type" : "" },
{ "@type" : "" }

No further specification is necessary to redact files this way, unlike the multipart/form-data method outlined above. Now, you can save the YAML file, go back to your Routes page on the dashboard, click on Manage, and upload it: 


With this configuration saved, we can upload any file and will be aliased:


Once aliased, the entire file's raw contents are contained within the alias, and can be revealed as needed. 

Was this article helpful?
0 out of 0 found this helpful



Please sign in to leave a comment.