cordova-plugin-openwith icon indicating copy to clipboard operation
cordova-plugin-openwith copied to clipboard

Description needs more clarity

Open fega opened this issue 5 years ago • 1 comments

Hello, thanks for your work in the plugin

I have seen multiple forks and issues related with the lack of support of more data types. as far I see there is not intention to add this kind of support to this plugin, so probably the correct thing to do is to specify in the description about it (that this plugin is only intended to support images), to avoid misleading ideas.

thanks

fega avatar Jan 17 '20 15:01 fega

i've tried share mp4, pdf from file manager on android, it works. havent try ios yet.

and when i click share on chrome menu it shares an image not url

import axios from 'axios'

const fileReaderSync = file => new Promise(resolve => {
  const reader = new FileReader()
  reader.onloadend = function () {
    var blob = new Blob([new Uint8Array(this.result)], { type: file.type })
    resolve(blob)
  }
  reader.readAsArrayBuffer(file)
})

const resolveLocalFileSystemURLSync = uri => new Promise(resolve => {
  window.resolveLocalFileSystemURL(uri, function (fileEntry) {
    fileEntry.file(resolve)
  })
})


Meteor.startup(function () {
  cordova.openwith.init(function () {
    cordova.openwith.addHandler(async function (intent) {
      const data = new FormData()

      if (intent.items.length > 0) {
        for (const item of intent.items) {
          const file = await resolveLocalFileSystemURLSync(item.uri)
          const blob = await fileReaderSync(file)
          data.append('files', blob)
        }

        axios({
          method: 'post',
          url: 'http://192.168.50.76:3000/api/upload',
          data,
          headers: {'Content-Type': 'multipart/form-data' }
        })
        .then(function (response) {
          alert(JSON.stringify(response, null, 2));
        })
        .catch(function (response) {
          alert(response);
        })
      }
    })
  }, function () {
    alert('failed')
  })
})

And i'm using meteor this is "mobile-config.js" that i added for this plugin

App.configurePlugin('cc.fovea.cordova.openwith', {
  ANDROID_MIME_TYPE: '*/*',
  IOS_URL_SCHEME: 'ccfoveaopenwithdemo',
  IOS_UNIFORM_TYPE_IDENTIFIER: 'public.image',
})

crapthings avatar Feb 02 '20 14:02 crapthings