How to fix NativeScript file upload on some files aborts the upload after just 196608 bytes
On some files, (ios) at the moment is the only platform I'm testing on, if the file is under 30 megs everything seems to work using nativescript-background-http to upload a video file to the server. If the filesize is over 30 megs the upload aborts at exactly 196608 bytes every time.
I know it's not a server issue aborting the upload. As I have set both the POST Size Limits in IIS and the Max File Size Limit in ColdFusion to 500 megs.
mediafilepicker.on("getFiles", function (res) {
let results = res.object.get('results');
if (results) {
for (let i = 0; i < results.length; i++) {
let result = results[i];
let file = result.file;
if (result.file && applicationModule.ios)
{
console.dir(result);
// We can copy it to app directory, if need
//let fileName = "myTmpImage.mov";
var session = bghttp.session("image-upload");
var sFile = result.file.replace("file://", "");
var filename = sFile.substring(sFile.lastIndexOf('/') + 1);
var mimetype = filename.substring(filename.lastIndexOf('.') + 1);
console.log(sFile);
var request = {
url: 'http://www.mobilecoach.me/test_upload.cfm',
method: "POST",
headers: {
"Content-Type": "application/octet-stream",
"File-Name" : filename
},
description: "Uploading"
};
var params = [
{ name: "file", filename: sFile, mimeType: "video/" + mimetype }
];
task = session.multipartUpload(params, request);
task.on("progress", logEvent);
task.on("error", logEvent);
task.on("complete", logEvent);
function logEvent(e) {
console.log("currentBytes: " + e.currentBytes);
console.log("totalBytes: " + e.totalBytes);
console.log(e.eventName);
if(e.eventName == "complete")
{
dialogsModule.alert({
message: "Upload Completed",
okButtonText: "Ok",
cancelable: false
}).then(() => {
})
}
}
}
}
}
});
Like I said on less than 30 meg files works fine. Over 30 megs upload aborts without error just completes/aborts @ exactly 196608 bytes.
ios file upload nativescript upload-max-filesize
|
show 4 more comments
On some files, (ios) at the moment is the only platform I'm testing on, if the file is under 30 megs everything seems to work using nativescript-background-http to upload a video file to the server. If the filesize is over 30 megs the upload aborts at exactly 196608 bytes every time.
I know it's not a server issue aborting the upload. As I have set both the POST Size Limits in IIS and the Max File Size Limit in ColdFusion to 500 megs.
mediafilepicker.on("getFiles", function (res) {
let results = res.object.get('results');
if (results) {
for (let i = 0; i < results.length; i++) {
let result = results[i];
let file = result.file;
if (result.file && applicationModule.ios)
{
console.dir(result);
// We can copy it to app directory, if need
//let fileName = "myTmpImage.mov";
var session = bghttp.session("image-upload");
var sFile = result.file.replace("file://", "");
var filename = sFile.substring(sFile.lastIndexOf('/') + 1);
var mimetype = filename.substring(filename.lastIndexOf('.') + 1);
console.log(sFile);
var request = {
url: 'http://www.mobilecoach.me/test_upload.cfm',
method: "POST",
headers: {
"Content-Type": "application/octet-stream",
"File-Name" : filename
},
description: "Uploading"
};
var params = [
{ name: "file", filename: sFile, mimeType: "video/" + mimetype }
];
task = session.multipartUpload(params, request);
task.on("progress", logEvent);
task.on("error", logEvent);
task.on("complete", logEvent);
function logEvent(e) {
console.log("currentBytes: " + e.currentBytes);
console.log("totalBytes: " + e.totalBytes);
console.log(e.eventName);
if(e.eventName == "complete")
{
dialogsModule.alert({
message: "Upload Completed",
okButtonText: "Ok",
cancelable: false
}).then(() => {
})
}
}
}
}
}
});
Like I said on less than 30 meg files works fine. Over 30 megs upload aborts without error just completes/aborts @ exactly 196608 bytes.
ios file upload nativescript upload-max-filesize
did you try to upload it outside of nativescript to make sure it's working? (maybe with Postman)
– Bass
Jan 2 at 16:58
Do you keep the screen on & app active while uploading? Do you get any error? As mentioned above, did you get a chance to verify your API with tools like Postman?
– Manoj
Jan 2 at 19:33
Okay so here's what I've been able to diagnose so far if I console.dir(e) inside the logEvent method here is what I get...
– Brent Ziemann
Jan 2 at 20:27
responseCode: 200 response: <NSHTTPURLResponse: 0x2829061a0> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 200, Headers { "Content-Encoding" = ( gzip ); "Content-Length" = ( 120 ); "Content-Type" = ( "text/html;charset=UTF-8" ); Date = ( "Wed, 02 Jan 2019 17:15:01 GMT" ); Server = ( "Microsoft-IIS/10.0" ); Vary = ( "Accept-Encoding" ); "X-Powered-By" = ( "ASP.NET" ); } } That is on success
– Brent Ziemann
Jan 2 at 20:28
responseCode: 404 response: <NSHTTPURLResponse: 0x282928500> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 404, Headers { "Cache-Control" = ( private ); Connection = ( close ); "Content-Length" = ( 4982 ); "Content-Type" = ( "text/html; charset=utf-8" ); Date = ( "Wed, 02 Jan 2019 17:15:43 GMT" ); Server = ( "Microsoft-IIS/10.0" ); "X-Powered-By" = ( "ASP.NET" ); } } This is when it fails...
– Brent Ziemann
Jan 2 at 20:29
|
show 4 more comments
On some files, (ios) at the moment is the only platform I'm testing on, if the file is under 30 megs everything seems to work using nativescript-background-http to upload a video file to the server. If the filesize is over 30 megs the upload aborts at exactly 196608 bytes every time.
I know it's not a server issue aborting the upload. As I have set both the POST Size Limits in IIS and the Max File Size Limit in ColdFusion to 500 megs.
mediafilepicker.on("getFiles", function (res) {
let results = res.object.get('results');
if (results) {
for (let i = 0; i < results.length; i++) {
let result = results[i];
let file = result.file;
if (result.file && applicationModule.ios)
{
console.dir(result);
// We can copy it to app directory, if need
//let fileName = "myTmpImage.mov";
var session = bghttp.session("image-upload");
var sFile = result.file.replace("file://", "");
var filename = sFile.substring(sFile.lastIndexOf('/') + 1);
var mimetype = filename.substring(filename.lastIndexOf('.') + 1);
console.log(sFile);
var request = {
url: 'http://www.mobilecoach.me/test_upload.cfm',
method: "POST",
headers: {
"Content-Type": "application/octet-stream",
"File-Name" : filename
},
description: "Uploading"
};
var params = [
{ name: "file", filename: sFile, mimeType: "video/" + mimetype }
];
task = session.multipartUpload(params, request);
task.on("progress", logEvent);
task.on("error", logEvent);
task.on("complete", logEvent);
function logEvent(e) {
console.log("currentBytes: " + e.currentBytes);
console.log("totalBytes: " + e.totalBytes);
console.log(e.eventName);
if(e.eventName == "complete")
{
dialogsModule.alert({
message: "Upload Completed",
okButtonText: "Ok",
cancelable: false
}).then(() => {
})
}
}
}
}
}
});
Like I said on less than 30 meg files works fine. Over 30 megs upload aborts without error just completes/aborts @ exactly 196608 bytes.
ios file upload nativescript upload-max-filesize
On some files, (ios) at the moment is the only platform I'm testing on, if the file is under 30 megs everything seems to work using nativescript-background-http to upload a video file to the server. If the filesize is over 30 megs the upload aborts at exactly 196608 bytes every time.
I know it's not a server issue aborting the upload. As I have set both the POST Size Limits in IIS and the Max File Size Limit in ColdFusion to 500 megs.
mediafilepicker.on("getFiles", function (res) {
let results = res.object.get('results');
if (results) {
for (let i = 0; i < results.length; i++) {
let result = results[i];
let file = result.file;
if (result.file && applicationModule.ios)
{
console.dir(result);
// We can copy it to app directory, if need
//let fileName = "myTmpImage.mov";
var session = bghttp.session("image-upload");
var sFile = result.file.replace("file://", "");
var filename = sFile.substring(sFile.lastIndexOf('/') + 1);
var mimetype = filename.substring(filename.lastIndexOf('.') + 1);
console.log(sFile);
var request = {
url: 'http://www.mobilecoach.me/test_upload.cfm',
method: "POST",
headers: {
"Content-Type": "application/octet-stream",
"File-Name" : filename
},
description: "Uploading"
};
var params = [
{ name: "file", filename: sFile, mimeType: "video/" + mimetype }
];
task = session.multipartUpload(params, request);
task.on("progress", logEvent);
task.on("error", logEvent);
task.on("complete", logEvent);
function logEvent(e) {
console.log("currentBytes: " + e.currentBytes);
console.log("totalBytes: " + e.totalBytes);
console.log(e.eventName);
if(e.eventName == "complete")
{
dialogsModule.alert({
message: "Upload Completed",
okButtonText: "Ok",
cancelable: false
}).then(() => {
})
}
}
}
}
}
});
Like I said on less than 30 meg files works fine. Over 30 megs upload aborts without error just completes/aborts @ exactly 196608 bytes.
ios file upload nativescript upload-max-filesize
ios file upload nativescript upload-max-filesize
edited Jan 2 at 16:39


AS Mackay
2,01351121
2,01351121
asked Jan 2 at 16:34
Brent ZiemannBrent Ziemann
11
11
did you try to upload it outside of nativescript to make sure it's working? (maybe with Postman)
– Bass
Jan 2 at 16:58
Do you keep the screen on & app active while uploading? Do you get any error? As mentioned above, did you get a chance to verify your API with tools like Postman?
– Manoj
Jan 2 at 19:33
Okay so here's what I've been able to diagnose so far if I console.dir(e) inside the logEvent method here is what I get...
– Brent Ziemann
Jan 2 at 20:27
responseCode: 200 response: <NSHTTPURLResponse: 0x2829061a0> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 200, Headers { "Content-Encoding" = ( gzip ); "Content-Length" = ( 120 ); "Content-Type" = ( "text/html;charset=UTF-8" ); Date = ( "Wed, 02 Jan 2019 17:15:01 GMT" ); Server = ( "Microsoft-IIS/10.0" ); Vary = ( "Accept-Encoding" ); "X-Powered-By" = ( "ASP.NET" ); } } That is on success
– Brent Ziemann
Jan 2 at 20:28
responseCode: 404 response: <NSHTTPURLResponse: 0x282928500> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 404, Headers { "Cache-Control" = ( private ); Connection = ( close ); "Content-Length" = ( 4982 ); "Content-Type" = ( "text/html; charset=utf-8" ); Date = ( "Wed, 02 Jan 2019 17:15:43 GMT" ); Server = ( "Microsoft-IIS/10.0" ); "X-Powered-By" = ( "ASP.NET" ); } } This is when it fails...
– Brent Ziemann
Jan 2 at 20:29
|
show 4 more comments
did you try to upload it outside of nativescript to make sure it's working? (maybe with Postman)
– Bass
Jan 2 at 16:58
Do you keep the screen on & app active while uploading? Do you get any error? As mentioned above, did you get a chance to verify your API with tools like Postman?
– Manoj
Jan 2 at 19:33
Okay so here's what I've been able to diagnose so far if I console.dir(e) inside the logEvent method here is what I get...
– Brent Ziemann
Jan 2 at 20:27
responseCode: 200 response: <NSHTTPURLResponse: 0x2829061a0> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 200, Headers { "Content-Encoding" = ( gzip ); "Content-Length" = ( 120 ); "Content-Type" = ( "text/html;charset=UTF-8" ); Date = ( "Wed, 02 Jan 2019 17:15:01 GMT" ); Server = ( "Microsoft-IIS/10.0" ); Vary = ( "Accept-Encoding" ); "X-Powered-By" = ( "ASP.NET" ); } } That is on success
– Brent Ziemann
Jan 2 at 20:28
responseCode: 404 response: <NSHTTPURLResponse: 0x282928500> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 404, Headers { "Cache-Control" = ( private ); Connection = ( close ); "Content-Length" = ( 4982 ); "Content-Type" = ( "text/html; charset=utf-8" ); Date = ( "Wed, 02 Jan 2019 17:15:43 GMT" ); Server = ( "Microsoft-IIS/10.0" ); "X-Powered-By" = ( "ASP.NET" ); } } This is when it fails...
– Brent Ziemann
Jan 2 at 20:29
did you try to upload it outside of nativescript to make sure it's working? (maybe with Postman)
– Bass
Jan 2 at 16:58
did you try to upload it outside of nativescript to make sure it's working? (maybe with Postman)
– Bass
Jan 2 at 16:58
Do you keep the screen on & app active while uploading? Do you get any error? As mentioned above, did you get a chance to verify your API with tools like Postman?
– Manoj
Jan 2 at 19:33
Do you keep the screen on & app active while uploading? Do you get any error? As mentioned above, did you get a chance to verify your API with tools like Postman?
– Manoj
Jan 2 at 19:33
Okay so here's what I've been able to diagnose so far if I console.dir(e) inside the logEvent method here is what I get...
– Brent Ziemann
Jan 2 at 20:27
Okay so here's what I've been able to diagnose so far if I console.dir(e) inside the logEvent method here is what I get...
– Brent Ziemann
Jan 2 at 20:27
responseCode: 200 response: <NSHTTPURLResponse: 0x2829061a0> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 200, Headers { "Content-Encoding" = ( gzip ); "Content-Length" = ( 120 ); "Content-Type" = ( "text/html;charset=UTF-8" ); Date = ( "Wed, 02 Jan 2019 17:15:01 GMT" ); Server = ( "Microsoft-IIS/10.0" ); Vary = ( "Accept-Encoding" ); "X-Powered-By" = ( "ASP.NET" ); } } That is on success
– Brent Ziemann
Jan 2 at 20:28
responseCode: 200 response: <NSHTTPURLResponse: 0x2829061a0> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 200, Headers { "Content-Encoding" = ( gzip ); "Content-Length" = ( 120 ); "Content-Type" = ( "text/html;charset=UTF-8" ); Date = ( "Wed, 02 Jan 2019 17:15:01 GMT" ); Server = ( "Microsoft-IIS/10.0" ); Vary = ( "Accept-Encoding" ); "X-Powered-By" = ( "ASP.NET" ); } } That is on success
– Brent Ziemann
Jan 2 at 20:28
responseCode: 404 response: <NSHTTPURLResponse: 0x282928500> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 404, Headers { "Cache-Control" = ( private ); Connection = ( close ); "Content-Length" = ( 4982 ); "Content-Type" = ( "text/html; charset=utf-8" ); Date = ( "Wed, 02 Jan 2019 17:15:43 GMT" ); Server = ( "Microsoft-IIS/10.0" ); "X-Powered-By" = ( "ASP.NET" ); } } This is when it fails...
– Brent Ziemann
Jan 2 at 20:29
responseCode: 404 response: <NSHTTPURLResponse: 0x282928500> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 404, Headers { "Cache-Control" = ( private ); Connection = ( close ); "Content-Length" = ( 4982 ); "Content-Type" = ( "text/html; charset=utf-8" ); Date = ( "Wed, 02 Jan 2019 17:15:43 GMT" ); Server = ( "Microsoft-IIS/10.0" ); "X-Powered-By" = ( "ASP.NET" ); } } This is when it fails...
– Brent Ziemann
Jan 2 at 20:29
|
show 4 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54009905%2fhow-to-fix-nativescript-file-upload-on-some-files-aborts-the-upload-after-just-1%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54009905%2fhow-to-fix-nativescript-file-upload-on-some-files-aborts-the-upload-after-just-1%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
did you try to upload it outside of nativescript to make sure it's working? (maybe with Postman)
– Bass
Jan 2 at 16:58
Do you keep the screen on & app active while uploading? Do you get any error? As mentioned above, did you get a chance to verify your API with tools like Postman?
– Manoj
Jan 2 at 19:33
Okay so here's what I've been able to diagnose so far if I console.dir(e) inside the logEvent method here is what I get...
– Brent Ziemann
Jan 2 at 20:27
responseCode: 200 response: <NSHTTPURLResponse: 0x2829061a0> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 200, Headers { "Content-Encoding" = ( gzip ); "Content-Length" = ( 120 ); "Content-Type" = ( "text/html;charset=UTF-8" ); Date = ( "Wed, 02 Jan 2019 17:15:01 GMT" ); Server = ( "Microsoft-IIS/10.0" ); Vary = ( "Accept-Encoding" ); "X-Powered-By" = ( "ASP.NET" ); } } That is on success
– Brent Ziemann
Jan 2 at 20:28
responseCode: 404 response: <NSHTTPURLResponse: 0x282928500> { URL: mobilecoach.me/test_upload.cfm } { Status Code: 404, Headers { "Cache-Control" = ( private ); Connection = ( close ); "Content-Length" = ( 4982 ); "Content-Type" = ( "text/html; charset=utf-8" ); Date = ( "Wed, 02 Jan 2019 17:15:43 GMT" ); Server = ( "Microsoft-IIS/10.0" ); "X-Powered-By" = ( "ASP.NET" ); } } This is when it fails...
– Brent Ziemann
Jan 2 at 20:29