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

Share pdf file to this app and render it Android/IOS #6

Open
wants to merge 1 commit into
base: playground
Choose a base branch
from

Conversation

Zeljko-Predjeskovic
Copy link
Owner

No description provided.

var pdf = Intent.ClipData.GetItemAt(0);

// Open a stream from the URI
var pdfStream = ContentResolver.OpenInputStream(pdf.Uri);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we need the ContentResolver, to get the file stream - we cannot use "File.OpenRead"
=> in iCL Filler, please copy the stream to the temp folder of iCL Filler.
This is a folder that is inside the apps root older, so we can easily access it using "File.OpenRead".
That way, we can use the stream multiple times (e.g. insert a plan to multiple fields, not just one)

When the user places the shared file, iCL Filler can simply read it from the temp-file.
Once it has been used, it should be deleted.


public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
SharedStream.Instance = System.IO.File.Open(url.Path, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are receiving a file from the operating system.
You will most certainly not be able to "create" it or "write" to that stream.
So pelase only open it with "File.OpenRead"! (Or do I misunderstand something?)

{
private static Stream _stream;

public static Stream Instance
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... having a static "Stream" is not the best option as it is not memory-efficient and you can only access this stream once. So you cannot check what type of file it is, or what is contained without actually consuming this file!
Better is to

  • copy the shared file to a temp folder (within the apps root folder)
  • in the SharedFilesService have the path to the temp file as CurrentlySharedFile.

that way

  • you can read this file as often as you want
  • you can determine, what kind of file it is (pdf, jpeg, png, ...?)
  • you can even keep this shared file after the app is being restarted, because this file is still within the temp folder of the app.
    A shared file will not be accessible anymore after an application restart!

public ShareButton()
{
InitializeComponent();
SharedVisibles.Visibles.Attach(this);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this Attach doing?

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

Successfully merging this pull request may close these issues.

2 participants