phonefile

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package phonefile implements the multi-step file upload used by cloud phones.

The flow mirrors the PMOCK client:

  1. POST /open/api/phone/minio/init/task -> uploadId + per-part presigned URLs
  2. PUT each missing part to its presigned URL, collecting ETags
  3. POST /open/api/phone/completeAndPush -> merge (OBS) and push to the phone

MinIO merges server-side, so mergeList is empty; OBS requires the ETag list.

Index

Constants

View Source
const (
	// TypeApp marks the upload as an APK/app asset.
	TypeApp = 1
	// TypeFile marks the upload as a temporary file.
	TypeFile = 2

	// MaxFileSize is the documented open API limit.
	MaxFileSize int64 = 1 << 30
	// DefaultChunkSize is the documented minimum chunk size.
	DefaultChunkSize int64 = 30 << 20
	// MaxChunkSize is the documented maximum chunk size.
	MaxChunkSize int64 = 300 << 20
)

Variables

This section is empty.

Functions

func MD5File

func MD5File(path string) (string, error)

MD5File streams the file through MD5.

Types

type Options

type Options struct {
	PhoneID    int64
	FilePath   string
	UploadType int // TypeApp or TypeFile
	DestDir    string
	ChunkSize  int64
	MD5        string
}

Options describes one upload.

type Plan

type Plan struct {
	FileName   string
	Size       int64
	MD5        string
	ChunkSize  int64
	ChunkNum   int
	UploadType int
	PhoneID    int64
	DestDir    string
}

Plan is the local, network-free part of an upload.

func PlanFile

func PlanFile(opts Options) (*Plan, error)

PlanFile validates the file and computes the metadata needed to init a task.

type Uploader

type Uploader struct {
	Client   *client.Client
	HTTP     *http.Client
	Progress func(part, total int)
}

Uploader performs uploads with one API client and one plain HTTP client.

func New

func New(c *client.Client) *Uploader

New builds an Uploader.

func (*Uploader) Upload

func (u *Uploader) Upload(ctx context.Context, opts Options) (*client.Envelope, error)

Upload runs init -> parts -> complete. The returned envelope is the last response received, so business failures can still be rendered by the caller.

Jump to

Keyboard shortcuts

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