change file attachment before send/upload

421 views
Skip to first unread message

Ori

unread,
Oct 27, 2016, 3:51:23 AM10/27/16
to InboxSDK
Hey all , I am new with inboxSDK . I  want to create some chrome extension that encrypt/decrypt text & attachments
If some people add file from the regular gmail attachments button can I changed the file or the content of the file before it's uploaded ( I want to encrypt the file before upload to compose window) ? I see in the documentation only the attachFiles method  but not any action to the button that upload attachment of gmail or some access to the  files in compose mode....

someone have any idea for me ? Thanks for your help !

Chris Cowan

unread,
Oct 28, 2016, 5:58:11 PM10/28/16
to InboxSDK
You could accomplish this by using ComposeView.addButton to add an "encrypt & attach file" button which opens an open-file dialog, you can process the file into a Blob object containing the encrypted data, and then you can use ComposeView.attachFiles to attach the encrypted file into the composeview. (When the composeview is created, create a hidden <input type=file> element on document.body with its change event handler set to read the file, encrypt it, make a Blob object containing the encrypted data, and then call ComposeView.attachFiles with that. When the composeview emits its destroy event, remove the file input element from the page. Add an "encrypt & attach file" button to the composeview which clears the file input by setting its value to '', and then opens it by calling its click() method.)

Ori

unread,
Oct 31, 2016, 6:54:10 AM10/31/16
to InboxSDK
hey chris and thank for your answer!
I want to make sure... what you mean is to create a new button and that everyone will upload files from this button and not from the original button ... not have another way to use the original button instead to create a new one?

And another little question... can i add somehow mark to message  and then when i see this message to see this mark .. I want to add a mark to encrypt message and when i view some mail to check the mark if it's encrypt or not and then to know if to decrypt it.... maybe you know some way ?


thank , you are great really !

בתאריך יום שבת, 29 באוקטובר 2016 בשעה 00:58:11 UTC+3, מאת Chris Cowan:

Chris Cowan

unread,
Oct 31, 2016, 2:19:49 PM10/31/16
to InboxSDK
We don't currently support the ability to intercept the original attachment button or the ability to retrieve or manipulate a draft's existing attachments.

You can register a MessageView handler, use .getBodyElement(), and then inspect it for special text (or element attributes) to trigger decoding, and then you could do something like use .addAttachmentIcon to put an icon on the message marking it as decrypted if you wanted.

In the inbox and other thread list pages, if you know the thread/draft ids of encrypted messages, then you could register a ThreadRowView handler, check the threadrow by id to see if it's encrypted, and then use .addAttachmentIcon to mark the threadrow.
Reply all
Reply to author
Forward
0 new messages