{"action":"created","issue":{"url":"https://api.github.com/repos/nittro/nittro/issues/32","repository_url":"https://api.github.com/repos/nittro/nittro","labels_url":"https://api.github.com/repos/nittro/nittro/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/nittro/nittro/issues/32/comments","events_url":"https://api.github.com/repos/nittro/nittro/issues/32/events","html_url":"https://github.com/nittro/nittro/issues/32","id":362891766,"node_id":"MDU6SXNzdWUzNjI4OTE3NjY=","number":32,"title":"upload","user":{"login":"vylink","id":33554515,"node_id":"MDQ6VXNlcjMzNTU0NTE1","avatar_url":"https://avatars2.githubusercontent.com/u/33554515?v=4","gravatar_id":"","url":"https://api.github.com/users/vylink","html_url":"https://github.com/vylink","followers_url":"https://api.github.com/users/vylink/followers","following_url":"https://api.github.com/users/vylink/following{/other_user}","gists_url":"https://api.github.com/users/vylink/gists{/gist_id}","starred_url":"https://api.github.com/users/vylink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vylink/subscriptions","organizations_url":"https://api.github.com/users/vylink/orgs","repos_url":"https://api.github.com/users/vylink/repos","events_url":"https://api.github.com/users/vylink/events{/privacy}","received_events_url":"https://api.github.com/users/vylink/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-22T21:21:09Z","updated_at":"2018-09-23T17:12:55Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\ncan you help me with the ajax upload, please?\r\nI'm not sure, how can I send a file from the dropzone to the server\r\n\r\n\r\n```\r\ndropzone.on('file', (evt) => {\r\n        const formData = new FormData()\r\n        formData.append('file', evt.data.file);\r\n        this.di.getService('page').open('/somepresenter/?do=upload', 'POST', formData)\r\n});\r\n```\r\n\r\n\r\nMany thanks,\r\n\r\nM"},"comment":{"url":"https://api.github.com/repos/nittro/nittro/issues/comments/423831817","html_url":"https://github.com/nittro/nittro/issues/32#issuecomment-423831817","issue_url":"https://api.github.com/repos/nittro/nittro/issues/32","id":423831817,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzgzMTgxNw==","user":{"login":"jahudka","id":330635,"node_id":"MDQ6VXNlcjMzMDYzNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/330635?v=4","gravatar_id":"","url":"https://api.github.com/users/jahudka","html_url":"https://github.com/jahudka","followers_url":"https://api.github.com/users/jahudka/followers","following_url":"https://api.github.com/users/jahudka/following{/other_user}","gists_url":"https://api.github.com/users/jahudka/gists{/gist_id}","starred_url":"https://api.github.com/users/jahudka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jahudka/subscriptions","organizations_url":"https://api.github.com/users/jahudka/orgs","repos_url":"https://api.github.com/users/jahudka/repos","events_url":"https://api.github.com/users/jahudka/events{/privacy}","received_events_url":"https://api.github.com/users/jahudka/received_events","type":"User","site_admin":false},"created_at":"2018-09-23T17:12:55Z","updated_at":"2018-09-23T17:12:55Z","author_association":"MEMBER","body":"Hi, you're almost there - the easiest change to your code that should make it work would be to use `Nittro.Forms.FormData` instead of the native `FormData`, e.g.:\r\n\r\n```\r\n_context.invoke(function(FormData) {\r\n    // ...\r\n    const formData = new FormData();\r\n    // ...\r\n}, {\r\n    FormData: 'Nittro.Forms.FormData'\r\n});\r\n```\r\n\r\nIf your code is in an inline `<script>` tag in a template and your project uses the `_stack` library, just replace `_context.invoke(function(FormData) { ... }, { FormData: ... })` with `_stack.push([ function(FormData) { ... }, { FormData: ... } ])` (note that in the `_stack.push` call the arguments are wrapped in an array). You can also just get a reference to Nittro's FormData directly like this:\r\n\r\n```\r\nconst NittroFormData = _context.lookup('Nittro.Forms.FormData');\r\nconst formData = new NittroFormData();\r\n```\r\n\r\nNot sure about your `this.di` reference - within a `_context.invoke()`'d closure `this` points to the _current namespace_, which _can_ be the global namespace where `di` is stored, but not necessarily - if you later refactor your code and move it into a namespace, the `this.di` references will break - I'd recommend you just let `_context` inject the `di` instance as a parameter of your callback like this:\r\n```\r\n_context.invoke(function(di) {\r\n    // di.getService('...')...\r\n});\r\n```"}}
{"actor":{"display_login":"jahudka"}}