upload

package
v0.21.4 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package upload implements sending files by uploading them to an HTTP server.

Index

Constants

View Source
const NS = "urn:xmpp:http:upload:0"

NS is the namespace used by this package.

Variables

View Source
var (
	Feature = info.Feature{Var: NS}
)

A list of service discovery features that are supported by this package.

Functions

This section is empty.

Types

type File

type File struct {
	Name string
	Size int
	Type string
}

File describes a file to be uploaded.

func (File) MarshalXML

func (f File) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

MarshalXML implements xml.Marshaler.

func (File) TokenReader

func (f File) TokenReader() xml.TokenReader

TokenReader satisfies the xmlstream.Marshaler interface.

func (*File) UnmarshalXML

func (f *File) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements xml.Unmarshaler.

func (File) WriteXML

func (f File) WriteXML(w xmlstream.TokenWriter) (n int, err error)

WriteXML satisfies the xmlstream.WriterTo interface. It is like MarshalXML except it writes tokens to w.

type Slot

type Slot struct {
	PutURL *url.URL
	GetURL *url.URL

	// Header is the headers that will be set on put requests from the slot.
	// The only valid headers are "Authorization", "Cookie", and "Expires".
	// All other headers will be ignored.
	Header http.Header
}

Slot is a place where a file can be uploaded and later retrieved.

func GetSlot

func GetSlot(ctx context.Context, f File, to jid.JID, s *xmpp.Session) (Slot, error)

GetSlot requests a URL where we can upload a file.

func GetSlotIQ

func GetSlotIQ(ctx context.Context, f File, iq stanza.IQ, s *xmpp.Session) (Slot, error)

GetSlotIQ is like GetSlot except that it lets you customize the IQ. Changing the type of the IQ has no effect.

func (Slot) MarshalXML

func (s Slot) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

MarshalXML implements xml.Marshaler.

func (Slot) Put

func (s Slot) Put(ctx context.Context, body io.Reader) (*http.Request, error)

Put returns a put request with the appropriate headers that can be used to upload a file to the slot.

func (Slot) TokenReader

func (s Slot) TokenReader() xml.TokenReader

TokenReader satisfies the xmlstream.Marshaler interface.

func (*Slot) UnmarshalXML

func (s *Slot) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements xml.Unmarshaler.

func (Slot) WriteXML

func (s Slot) WriteXML(w xmlstream.TokenWriter) (n int, err error)

WriteXML satisfies the xmlstream.WriterTo interface. It is like MarshalXML except it writes tokens to w.

Jump to

Keyboard shortcuts

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