Documentation ¶
Overview ¶
Package drive is the Deta Drive service package.
The following is a simple Put operation example.
import ( "bufio" "fmt" "os" "github.com/deta/deta-go/deta" "github.com/deta/deta-go/service/drive" ) func main() { // Create a new Deta instance with a project key d, err := deta.New(deta.WithProjectKey("project_key")) if err != nil { fmt.Fprintf(os.Stderr, "failed to create new Deta instance:%v\n", \n) os.Exit(1) } // Create a new Drive instance called "drawings", provide the previously created Deta instance drawings, err := drive.New(d, "drawings") if err != nil { fmt.Fprintf(os.Stderr, "failed to create new Drive instance: %v\n", err) os.Exit(1) } // Open local file "art.svg" file, err := os.Open("./art.svg") if err != nil { fmt.Fprintf(os.Stderr, "failed to open file: %v\n", err) os.Exit(1) } defer file.Close() // Put "art.svg" to "drawings" name, err := drawings.Put(&drive.PutInput{ Name: "art.svg", Body: bufio.NewReader(file), ContentType: "image/svg+xml", }) if err != nil { fmt.Fprintf(os.Stderr, "failed to put file: %v\n", err) os.Exit(1) } fmt.Printf("successfully put file %s", name) }
More examples and complete documentation on https://docs.deta.sh/docs/drive/sdk/
Package drive is the Deta Drive service package.
Index ¶
- type DeleteManyOutput
- type Drive
- func (d *Drive) Delete(name string) (string, error)
- func (d *Drive) DeleteMany(names []string) (*DeleteManyOutput, error)
- func (d *Drive) Get(name string) (io.ReadCloser, error)
- func (d *Drive) List(limit int, prefix, last string) (*ListOutput, error)
- func (d *Drive) Put(i *PutInput) (string, error)
- type ListOutput
- type PutInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeleteManyOutput ¶
type DeleteManyOutput struct { Deleted []string `json:"deleted"` Failed map[string]string `json:"failed"` }
DeleteManyOutput output for DeleteMany operation
type Drive ¶
type Drive struct {
// contains filtered or unexported fields
}
Drive is a Deta Drive service client that offers the API to make requests to Deta Drive
func (*Drive) Delete ¶
Delete a file from a Drive.
Returns name of file deleted (even if the file does not exist)
func (*Drive) DeleteMany ¶
func (d *Drive) DeleteMany(names []string) (*DeleteManyOutput, error)
DeleteMany deletes multiple files in a Drive.
Deletes at most 1000 files in a single request. The file names should be a string slice. Returns a pointer to DeleteManyOutput.
func (*Drive) Get ¶
func (d *Drive) Get(name string) (io.ReadCloser, error)
Get a file from the Drive.
Returns a io.ReadCloser for the file.
type ListOutput ¶
type ListOutput struct { // Pagination information Paging *paging `json:"paging"` // list of file names Names []string `json:"names"` }
ListOutput output for List operation.