Skip to content

Commit fa689c9

Browse files
authored
Merge pull request #313 from samuelantonioli/parse-file-content-type-fix
closed #311: Parse.File sends incorrect Content-Type to API
2 parents 8fade17 + 330c8aa commit fa689c9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/ParseFile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ var DefaultController = {
245245
// To directly upload a File, we use a REST-style AJAX request
246246
var headers = {
247247
'X-Parse-Application-ID': CoreManager.get('APPLICATION_ID'),
248-
'X-Parse-JavaScript-Key': CoreManager.get('JAVASCRIPT_KEY')
248+
'X-Parse-JavaScript-Key': CoreManager.get('JAVASCRIPT_KEY'),
249+
'Content-Type': source.type || (source.file? source.file.type : null)
249250
};
250251
var url = CoreManager.get('SERVER_URL');
251252
if (url[url.length - 1] !== '/') {

src/RESTController.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ const RESTController = {
125125
};
126126

127127
headers = headers || {};
128-
headers['Content-Type'] = 'text/plain'; // Avoid pre-flight
128+
if (typeof(headers['Content-Type']) !== 'string') {
129+
headers['Content-Type'] = 'text/plain'; // Avoid pre-flight
130+
}
129131
if (CoreManager.get('IS_NODE')) {
130132
headers['User-Agent'] = 'Parse/' + CoreManager.get('VERSION') +
131133
' (NodeJS ' + process.versions.node + ')';

0 commit comments

Comments
 (0)