os

package module
v0.0.0-...-dcfe1de Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 15 Imported by: 5

README

OS library

This module contains utilities to read and write files to multiple sources using URI schemes as:

URI scheme destination
:// File System folder
s3:// or s3s:// Simple Storage Service endpoint
http:// or https:// Http Service endpoint

Examples of use can be found in the read and write tests.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLenHeader

func AddLenHeader(content []byte) []byte

func AppendFileBatch

func AppendFileBatch(content []byte, path string, perm os.FileMode) error

AppendFileBatch appends a []byte to an existing file or to a new file if not there

func EnsureBucketNotification

func EnsureBucketNotification(uri, creds, filterSuffix string, arn *notification.Arn) (*minio.Client, error)

EnsureBucketNotification check that a bucket exists and if not it creates it If a bucket is created, and notification information is provided then creates a bucket notification

func IsFile

func IsFile(uri string) bool

func NewS3Client

func NewS3Client(uri, creds string) (client *minio.Client, bucketName, objectName string, err error)

func ReadFile

func ReadFile(uri, creds string) ([]byte, error)

ReadFile use this function to generically fetch a file from a URI regardless of the type of location the file is in supported URI schemes are: - if prefix http:// or https:// then fetches from http endpoint - if prefix is none then reads from file system - if prefix is s3:// or s3s:// then fetches from s3 bucket endpoint - if prefix is ftp then returns a not supported error credentials are valid for http and s3 URIs and follow the syntax "user:pwd"

func ReadFileBatch

func ReadFileBatch(path string) ([][]byte, error)

func ReadFileBatchFromBytes

func ReadFileBatchFromBytes(content []byte) ([][]byte, error)

func WriteFile

func WriteFile(content []byte, uri, creds string) error

WriteFile writes a file to a URI supported URI schemes are: - if prefix is none then writes to file system - if prefix is s3:// or s3s:// then put the file to s3 bucket endpoint - if prefix http:// or https:// then returns a not supported error - if prefix is ftp then returns a not supported error credentials are valid for s3 URIs and follow the syntax "user:pwd"

Types

type UriType

type UriType int64
const (
	File UriType = iota
	S3
	S3S
	Http
	Https
	Ftp
	Ftps
	Unknown
)

func ParseUriType

func ParseUriType(uri string) UriType

func (UriType) String

func (t UriType) String() string

Jump to

Keyboard shortcuts

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