Skip to content

Instantly share code, notes, and snippets.

@mankind
Forked from ashikajith/mask_s3_url.md
Created August 9, 2019 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mankind/52062d872a1b7cb1149d1626bae99afb to your computer and use it in GitHub Desktop.
Save mankind/52062d872a1b7cb1149d1626bae99afb to your computer and use it in GitHub Desktop.
Masking S3 URL

S3 Masking URL

For masking the url we created a seperate routes, controller to fetch the record and generate the url for the download file.

  app/controllers/ubiquity/fail_uploads_controller.rb
  
  def download_file
    params[:fileset_id]
    uuid = params[:uuid]
    s3_file_set_url = Ubiquity::ImporterClient.get_s3_url uuid
    url = s3_file_set_url.file_url_hash[params[:fileset_id]]
    redirect_to url
  end

We will be passing the File Set ID and the Work UUID to fetch the s3 url from the remote api server. Once we trigger the api we will get the corresponding s3 url for the specific file and we'll redirect to that particular url to download the file from s3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment