Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@cuberqaq/transfer-file

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cuberqaq/transfer-file

Polyfill of @zos/ble/transfer-file API for ZeppOS 2.0/2.1

latest
Source
npmnpm
Version
1.0.4-pre
Version published
Maintainers
1
Created
Source

transfer-file

Polyfill of @zos/ble/transfer-file API for ZeppOS 2.0/2.1 device.

Corrently not support "progress" event or cancel sending task.

Some api were not tested. I don't know whether it could work correctly.

This repo is for ZeppOS device,not app-side. see CuberQAQ/zepp-fs-side: Polyfill of transferFile API for ZeppOS 1.0/2.0/2.1 app-side for app-side polyfill.

1. Install

Use Command npm i @cuberqaq/transfer-file --save to install transfer-file in your ZeppOS Miniapp project.

2. Import & Use

In your app-side JavaScript source file, use this to import transfer-file:

import { TransferFile } from "@cuberqaq/transfer-file";

Then you can use the methods in the same way you do with @zos/ble/TransferFile. API Document see Zepp OS Developers Documentation

3. Example:

Receiving File:

import { TransferFile } from "@cuberqaq/transfer-file";

const transferFile = new TransferFile()
const inbox = transferFile.getInbox()

Page({
  onInit() {
    inbox.on('NEWFILE', function() {
      const fileObject = inbox.getNextFile()

      fileObject.on('change', (event) => {
        if (event.data.readyState === 'transferred') {
          console.log('transfered file success')
        } else (event.data.readyState === 'error') {
          console.log('error')
        }
      })
    })
  }
})

Send File:

import { TransferFile } from "@cuberqaq/transfer-file";

const transferFile = new TransferFile()
const outbox = transferFile.getOutbox()

Page({
  onInit() {
    const fileObject = outbox.enqueueFile("assets://logo.png", { test: 1})

    fileObject.on('change', (event) => {
      if (event.data.readyState === 'transferred') {
        console.log('transfered file success')
      } else (event.data.readyState === 'error') {
        console.log('error')
      }
    })
  }
})

By the way, it seems that the transfering speed could only reach 8kb/s :(

Keywords

zeppos

FAQs

Package last updated on 20 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts