Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Description needs more clarity #90

Open
fega opened this issue Jan 17, 2020 · 1 comment
Open

Description needs more clarity #90

fega opened this issue Jan 17, 2020 · 1 comment

Comments

@fega
Copy link

fega commented Jan 17, 2020

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

@crapthings
Copy link

crapthings commented Feb 2, 2020

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',
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants