将图像/视频保存到html本地文件系统

时间:2018-01-09 06:51:07

标签: javascript jquery html5 filesystems html5-filesystem

使用HTML5本地文件系统API可以轻松保存基于文本和文本的blob。但是如何保存图像/视频等二进制文件呢?就像我输入

一样
const functions = require('firebase-functions')
const admin = require('firebase-admin')

admin.initializeApp(functions.config().firebase)

const stripe = require('stripe')(functions.config().stripe.testkey)

exports.stripeCharge = functions.firestore
  .document('/users/{userId}/payments/{paymentId}')
  .onWrite(event => {
    const payment = event.data
    const userId = event.params.userId
    const paymentId = event.params.paymentId

    // checks if payment exists or if it has already been charged
    if (!payment || payment.charge) return

    return admin.firestore
      .document(`/users/${userId}`)
      .get()
      .then(snapshot => {
        return snapshot
      })
      .then(customer => {
        const amount = payment.amount;
        const idempotency_key = paymentId  // prevent duplicate charges
        const source = payment.token.id
        const currency = 'usd'
        const description = 'irl Map Fine Print'
        const charge = {amount, currency, source}

        return stripe.charges.create(charge, { idempotency_key })
     })
     .then(charge => {
       admin.firestore
        .fieldValue(`/users/${userId}/payments/${paymentId}/charge`)
        .set(charge)
     })
   })

通过jquery访问它......

<input class="LoadMedia" type="files" multiple>

假设我已经初始化了文件系统,我该如何存储文件?

0 个答案:

没有答案