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

Plugin adds .plain to text extension when pass base64 #1104

Closed
moeatsy opened this issue Jun 16, 2020 · 2 comments
Closed

Plugin adds .plain to text extension when pass base64 #1104

moeatsy opened this issue Jun 16, 2020 · 2 comments

Comments

@moeatsy
Copy link

moeatsy commented Jun 16, 2020

 const reader = new FileReader();

  reader.onloadend = () => {
    console.log(blob.type) // 'text/plain'
    plugins.socialsharing.share(null, name, reader.result, null);
  };
  reader.readAsDataURL(blob);

When I trying to share text file at andoid, it adds .plain extension so new file name is file.txt.plain

@moeatsy
Copy link
Author

moeatsy commented Jun 16, 2020

have equal issue with xls files, its add .csv.vnd.ms-excel

@moeatsy moeatsy changed the title Plugin adds .plain to text extension Plugin adds .plain to text extension when pass base64 Jun 16, 2020
@moeatsy
Copy link
Author

moeatsy commented Jun 17, 2020

fixed, library parsing filename from base64 string in different order rather than reader output


 const reader = new FileReader();
  const { type } = blob;

  reader.onloadend = () => {
    const base64Data = reader.result.substr(reader.result.indexOf('base64,') + 7);

    plugins.socialsharing.shareWithOptions({
      files: [`df:${name};data:${type};base64,${base64Data}`],
    });
  };

  reader.readAsDataURL(blob);

thanks to issue #918

@moeatsy moeatsy closed this as completed Jun 17, 2020
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

1 participant