Socialsharing: gmail cannot attach file


#1

Hi,

i am trying to use the socialsharing plugin to attach a file to an email message using gmail.
IN the sharing dialog I select Gmal, then Gmail pops up and says it cannot attach empty files…

When i change the file access permissions of the file from rw------- to rw-rw-rw- by hand, Gmail has no problem attaching the file. Unfortunately i cannot change file permissions from my IONIC app, can I?

Here is my code:

// create file using cordova writeFile(), path is pointing to it
// should be ok, like ‘file:///data/data//files/test.csv’

$cordovaSocialSharing
.share(’…hiere my message…’, ‘some topic’, path, null)
.then(function(result) {
$log.debug("Share:Success " + result);
}, function(err) {
$log.debug("Share:Error - " + err);
});

Thanks a lot!


#2

Huh… i’ve never tried it with a file:// protocol, not sure it works with that? I.e i don’t believe it can actually “attach” a file to an email, the “file” parameter i use for things like images with public urls, works fine with facebook etc… and then when sharing via email it embeds the image at the bottom of the email. But i’ve never seen it add a file as an “attachment” to the email.


#3

Hi,

read file content as data-url $cordovaFile.readAsDataURL() and put the data (data:text/csv;base64,iVBORw0KGgoAAAANS...) to the social sharing plugin.

Example:

$cordovaFile.readAsDataURL(cordova.file.dataDirectory, 'test.csv')
.then(function (data) {
	$log.debug(data);
	data = data.replace('comma-separated-values', 'csv')
	$cordovaSocialSharing
	.share('...hiere my message...', 'some topic', data, null)
	.then(function(result) {
		$log.debug("Share:Success " + result);
	}, function(err) {
		$log.debug("Share:Error - " + err);
	});
}, function (error) {
   $log.debug( error);
});