ngrok

package
v0.0.0-...-a0e9b24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ngrok provides functionality to expose a locally hosted image to the public internet using ngrok tunneling.

This package implements the uploader.Uploader interface, allowing seamless integration with systems that require a publicly accessible URL for images.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Uploader

type Uploader struct {
	// contains filtered or unexported fields
}

Uploader is a struct that manages image storage and provides public URLs for images through an ngrok tunnel.

It implements the uploader.Uploader interface, enabling compatibility with systems that require image upload and public access capabilities.

func NewUploader

func NewUploader() *Uploader

NewUploader creates and initializes a new Uploader instance.

The Uploader uses an in-memory map to store images and can be configured to expose these images through a public URL using an ngrok tunnel.

Returns:

  • A pointer to the newly created Uploader instance.

func (*Uploader) StartServer

func (uploader *Uploader) StartServer(ctx context.Context)

StartServer starts an ngrok tunnel to expose the local HTTP server to the public internet. The public URL is stored in the Uploader for later use. This should be launched within a goroutine as this function does not return

Parameters:

  • ctx: The context to manage the lifecycle of the ngrok tunnel.

Returns:

  • An error if the tunnel fails to start.

func (*Uploader) Upload

func (uploader *Uploader) Upload(ctx context.Context, name string, img image.Image) (string, error)

Upload uploads the provided image with the specified name to a destination and returns a publicly accessible URL for the uploaded image.

Parameters:

ctx: The context for managing request deadlines, cancellation signals,
     and other request-scoped values.
name: The desired name or identifier for the uploaded image.
img: The image.Image object representing the image to upload.

Returns:

string: A publicly accessible URL where the uploaded image can be accessed.
error: An error object if the upload fails, or nil if the operation is successful.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL