Skip to content

digitalocean/sample-functions-golang-presigned-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample Function: Go "Presigned URL"

Introduction

This repository contains a sample presigned URL function written in Go. You are able to choose to get a presigned URL to upload a file to a DigitalOcean Space or to download a file from a DigitalOcean Space. You can deploy it on DigitalOcean's App Platform as a Serverless Function component. Documentation is available at https://docs.digitalocean.com/products/functions.

Requirements

Deploying the Function

# clone this repo
git clone https://github.com/digitalocean/sample-functions-golang-presigned-url
# deploy the project, using a remote build so that compiled executable matched runtime environment
> doctl serverless deploy sample-functions-golang-presigned-url --remote-build
Deploying 'sample-functions-golang-presigned-url'
  to namespace 'fn-...'
  on host 'https://faas-...'
Submitted action 'url' for remote building and deployment in runtime go:default (id: ...)

Deployed functions ('doctl sls fn get <funcName> --url' for URL):
  - presign/url

Using the Function

doctl serverless functions invoke presign/url -p filename:new-file.txt type:GET
{
  "body": "{presigned url}"
}

To get a presigned url using curl:

curl -X PUT -H 'Content-Type: application/json' {your-DO-app-url} -d '{"filename":"{filename}", "type":"GET or PUT"}'

To Upload or Download a file using curl:

curl -X PUT -d 'The contents of the file.' "{url}"

Learn More

You can learn more about Functions and App Platform integration in the official App Platform Documentation.

About

Creating a presigned url for DO's Spaces

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published