{"action":"created","issue":{"url":"https://api.github.com/repos/Rovak/InlineAttachment/issues/44","labels_url":"https://api.github.com/repos/Rovak/InlineAttachment/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/Rovak/InlineAttachment/issues/44/comments","events_url":"https://api.github.com/repos/Rovak/InlineAttachment/issues/44/events","html_url":"https://github.com/Rovak/InlineAttachment/pull/44","id":53644746,"number":44,"title":"Add settings.setupFormData","user":{"login":"choonkeat","id":473,"avatar_url":"https://avatars.githubusercontent.com/u/473?v=3","gravatar_id":"","url":"https://api.github.com/users/choonkeat","html_url":"https://github.com/choonkeat","followers_url":"https://api.github.com/users/choonkeat/followers","following_url":"https://api.github.com/users/choonkeat/following{/other_user}","gists_url":"https://api.github.com/users/choonkeat/gists{/gist_id}","starred_url":"https://api.github.com/users/choonkeat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/choonkeat/subscriptions","organizations_url":"https://api.github.com/users/choonkeat/orgs","repos_url":"https://api.github.com/users/choonkeat/repos","events_url":"https://api.github.com/users/choonkeat/events{/privacy}","received_events_url":"https://api.github.com/users/choonkeat/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-01-07T15:37:31Z","updated_at":"2015-01-10T14:49:21Z","closed_at":"2015-01-10T13:49:19Z","pull_request":{"url":"https://api.github.com/repos/Rovak/InlineAttachment/pulls/44","html_url":"https://github.com/Rovak/InlineAttachment/pull/44","diff_url":"https://github.com/Rovak/InlineAttachment/pull/44.diff","patch_url":"https://github.com/Rovak/InlineAttachment/pull/44.patch"},"body":"**1. Added `settings.setupFormData`**\r\n\r\nCurrently `settings.extraParams` appends more fields to the end, after the file itself (which would be very far down the http post payload). pickier server like [S3 direct file upload](https://aws.amazon.com/articles/1434) requires the other fields be in front in order to validate (and reject the upload) - **so i need to augment the `FormData` at the start**\r\n\r\nBut simply copying values over isn't enough, since some extra params are extracted from the file itself, e.g. `Content-Type` in S3 direct file upload. So the solution is to have parameters augmented via a function instead, and passing the `file` along.\r\n\r\nOptional: with `settings.setupFormData`, we can deprecate `settings.extraParams`\r\n\r\n**2. Added `data(`inlineattachment`)` so we can access the `inlineAttachment` instance.**\r\n\r\nIdeally I'd use `settings.onFileUploadResponse` to customize how I'd handle the S3 direct upload response and return false.\r\n\r\nUnfortunately, we cannot access most things that the default `inlineAttachment.prototype.onFileUploadResponse` has access to e.g. `this.settings.urlText`, `this.filenameTag`, `this.editor`\r\n\r\nOne approach is to obtain the `inlineAttachment` instance and attach a custom `onFileUploadResponse` function directly on it."},"comment":{"url":"https://api.github.com/repos/Rovak/InlineAttachment/issues/comments/69458248","html_url":"https://github.com/Rovak/InlineAttachment/pull/44#issuecomment-69458248","issue_url":"https://api.github.com/repos/Rovak/InlineAttachment/issues/44","id":69458248,"user":{"login":"choonkeat","id":473,"avatar_url":"https://avatars.githubusercontent.com/u/473?v=3","gravatar_id":"","url":"https://api.github.com/users/choonkeat","html_url":"https://github.com/choonkeat","followers_url":"https://api.github.com/users/choonkeat/followers","following_url":"https://api.github.com/users/choonkeat/following{/other_user}","gists_url":"https://api.github.com/users/choonkeat/gists{/gist_id}","starred_url":"https://api.github.com/users/choonkeat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/choonkeat/subscriptions","organizations_url":"https://api.github.com/users/choonkeat/orgs","repos_url":"https://api.github.com/users/choonkeat/repos","events_url":"https://api.github.com/users/choonkeat/events{/privacy}","received_events_url":"https://api.github.com/users/choonkeat/received_events","type":"User","site_admin":false},"created_at":"2015-01-10T14:49:21Z","updated_at":"2015-01-10T14:49:21Z","body":"oops, thanks for the cleanup! unfortunately this code sits after `isFileAllowed` need to get pass `allowedTypes.indexOf(file.type)`. it gets a little impractical to list possible `text/*`file types `text/plain`, `text/html`, `text/markdown`, `text/javascript`, ..."}}