Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/elcinzorlu/generate-pdf-and-upload-s3-go

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/elcinzorlu/generate-pdf-and-upload-s3-go

  • v0.0.0-20231021212134-19127749ad6f
  • Source
  • Go
  • Socket score

Version published
Created
Source

Golang HTML to PDF Converter and Upload AWS S3

The most commonly used file type is pdf and storage space is AWS S3. And this repository, which we use both, is a project where I can convert html files to pdf and upload our pdf files to AWS S3.

What it is?

In this repository, to obtain the html file to the pdf file with golang code blocks and upload it to AWS S3 as a repository.

Prerequisite

Install wkhtmltopdf using below command,

  • sudo apt install wkhtmltopdf - for Ubuntu

Steps to Follow

1. Create a sample HTML file inside of your project.
  • https://htmlpdfapi.com/blog/free_html5_invoice_templates - I used html5 template in this link.
2. Get go package using the below command for parsing the HTMl template.
  • go get github.com/SebastiaanKlippert/go-wkhtmltopdf
3. Get go package using the below command for upload AWS S3.
  • go get github.com/aws/aws-sdk-go/aws
  • go get github.com/aws/aws-sdk-go-v2/service/s3
  • go get github.com/aws/aws-sdk-go/aws/credentials
  • go get github.com/aws/aws-sdk-go/aws/session
4.Need to set the acl data;
  • Go to Bucket > Permissions Tab
  • Scroll to Object Ownership and click on Edit.
  • Change the settings as ACLs enabled, Bucket owner preferred

acl := "public-read" - can use this code block

and save changes.

5.Need to set the accesskeyid, secretaccesskey data;
  • If you dont have one already then go to your account and click on My Security Credentials

  • And then select Access keys (access key ID and secret access key) section.

  • There is an important notification on the section, which recommends you to create an IAM Role instead of creating root access keys.

  • Click on Create New Access Key

  • Download the Key pairs to your system for future use.

  • Click on Show Access key and you will get your Access Key ID and Secret Access Key.

6.Need to set the bucket, region data;
  • Once your account is setup login to your aws console https://console.aws.amazon.com and select S3 from services menu.

  • You can select S3 from the Storage section.

  • And then create a bucket in your S3.You could for example create one with your project name similar to . projectnameS3bucket788.

  • Select a region near to you and the click create.

  • You will have an S3 bucket created under your Amazon S3 section.

    7. Run below command
  • go run main.go

Resources

  • How to create an S3 Bucket and AWS Access Key ID and Secret Access Key for accessing it https://medium.com/@shamnad.p.s/how-to-create-an-s3-bucket-and-aws-access-key-id-and-secret-access-key-for-accessing-it-5653b6e54337

  • How to fix ACLs problems

    https://stackoverflow.com/questions/70333681/for-an-amazon-s3-bucket-deployment-from-github-how-do-i-fix-the-error-accesscont

  • How to convert html to pdf

    https://github.com/c-seeger/Golang-HTML-TO-PDF-Converter

  • How to updload aws s3

    https://gist.github.com/hiyali/6e3dd0b17d44ae92c1222011d6a6df8f

FAQs

Package last updated on 21 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc