大きなメディア ファイルをアップロードした際に、以下のような詳しい説明のないエラーが表示されることがあります。
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
このエラーは、メディア ファイルのサイズがMedia.MaxSizeInDatabase設定によって設定されたファイル サイズの制限を超えた場合に表示されます。
本来予期されているメッセージのフォーマットは次のとおりです。
The file {filename} is too big to be uploaded. The maximum size of a file that can be uploaded is 5 MB.
この問題を解決するには、以下の手順の実施を検討してください。
upload: function () { var that = this; this.startUploadTimer(this.datas); this.updateUploadInfo(true, true); //for each files - do the upload _.each(this.datas, function (data) { data.submit().error(function (jqXHR, textStatus, errorThrown) { if (jqXHR.status === 401) { _sc.Helpers.session.unauthorized(); return; } // Triggers error on each model that had an abort if (errorThrown === "abort") { that.app.trigger("upload-error", { id: data.__id }); } else { var errors = [{ Message: errorThrown }]; that.app.trigger("sc-error", errors); that.app.trigger("upload-error", { id: data.__id, errors: errors }); } }); }); },
upload: function () { var that = this; this.startUploadTimer(this.datas); this.updateUploadInfo(true, true); //for each files - do the upload _.each(this.datas, function (data) { data.submit().error(function (jqXHR, textStatus, errorThrown) { if (jqXHR.status === 401) { _sc.Helpers.session.unauthorized(); return; } // Triggers error on each model that had an abort if (jqXHR.responseText.indexOf('errorItems') != -1) { var errordata = jqXHR.responseText.split(''); var parsedJson = JSON.parse(errordata[1]); _.each(parsedJson.errorItems[1].Message, function (error) { error.id = data.__id; }); var errors = [{ Message: parsedJson.errorItems[1].Message }]; that.app.trigger("sc-error", errors); that.app.trigger("upload-error", { id: data.__id, errors: parsedJson.errorItems[1].Message }); return undefined; } else{ if (errorThrown === "abort") { that.app.trigger("upload-error", { id: data.__id }); } else { var errors = [{ Message: errorThrown }]; that.app.trigger("sc-error", errors); that.app.trigger("upload-error", { id: data.__id, errors: errors }); } } }); }); },