Rank: Advanced Member
Groups: Member
Joined: 11/30/2012(UTC) Posts: 61
Thanks: 6 times
|
Hi, I have several users testing the image uploading functionality of my web site using the Java Uploader. This uploads 3 resized files to Amazon S3 for each image selected and then calls a postback to my server with a list of filenames that were uploaded. The javascript looks something like this: Code: function DoUploadCallback(thisStatus) {
try
{
autoClose = thisStatus != 'D';
var s = '';
for (var i = 0, imax = files.length ; i < imax; i++) {
if (files[i].uploaded) {
s = s + ';' +
replaceDelimiter(files[i].origName, ';') + ';' +
replaceDelimiter(files[i].fileName, ';') + ';' +
replaceDelimiter(files[i].descr, ';');
}
else break;
}
if (s != '') callbackMain.PerformCallback(thisStatus + s);
}
catch (e) {
alert('Error in DoUploadCallback: ' + e.message);
}
finally {
popupProgress.Hide();
uploading = false;
mnuPhotos.SetEnabled(true);
DoUploadFileCountChange();
}
}
function DoUploadCallbackComplete(s, e) {
if (e.result != '0' && autoClose) window.close();
}
function DoBeforeUpload() {
try
{
files = [];
var ff = this.files();
// Loop through files and generate unique names for each file
for (var i = 0, imax = ff.count() ; i < imax; i++) {
var thisFile = ff.get(i);
var origName = thisFile.name();
var guid = thisFile.guid().slice(1, -1);
var fileName = guid + '.jpg';
var descr = thisFile.description();
files.push({
origName: origName,
fileName: fileName,
descr: descr,
uploaded: false
});
thisFile.description('');
}
startTime = new Date();
uploading = true;
mnuPhotos.SetEnabled(false);
popupProgress.Show();
}
catch (e) {
alert('Error in DoBeforeUpload: ' + e.message);
}
}
function DoBeforePackageUpload(packageIndex) {
fileIndex = packageIndex;
converterIndex = 0;
}
function DoAfterPackageUpload(packageIndex, response) {
try
{
if (packageIndex >= 0 && packageIndex < files.length) files[packageIndex].uploaded = true;
}
catch (e) {
alert('Error in DoAfterPackageUpload: ' + e.message);
}
finally {
DoUploadFileCountChange();
}
}
function DoBeforeSendRequest() {
try
{
var fileName = files[fileIndex].fileName;
var key = fileKeys[converterIndex];
var newKey = key.replace(/\$\{filename\}/, fileName);
as3.converters().get(converterIndex).key(newKey);
++converterIndex;
}
catch (e) {
alert('Error in DoBeforeSendRequest: ' + e.message);
}
}
function DoProgress(percent, uploadedFiles, totalFiles, uploadedBytes, totalBytes) {
try
{
var remainingFiles = totalFiles - uploadedFiles;
var bytesPercent = 0;
if (uploadedBytes > 0 && totalBytes > 0) bytesPercent = ~~((uploadedBytes / totalBytes) * 100);
if (uploadedFiles < files.length) DoUpdateLabel(lblProgressFilename, files[uploadedFiles].origName);
DoUpdateLabel(lblProgressUploaded, bytesToSize(uploadedBytes, 2));
DoUpdateLabel(lblProgressUploadedMax, bytesToSize(totalBytes, 2));
progress.SetPosition(bytesPercent);
if (uploadedFiles == 0 && uploadedBytes == 0) DoUpdateLabel(lblOverallProgress, 'Preparing images for upload...');
else DoUpdateLabel(lblOverallProgress, 'Uploading ' + (uploadedFiles + 1).toString() + ' of ' + totalFiles.toString() + ' (' + remainingFiles.toString() + ' remaining)');
DoUpdateLabel(lblElapsed, calculateElapsed(startTime));
progressOverall.SetPosition(percent);
}
catch (e) {
alert('Error in DoProgress: ' + e.message);
}
}
function DoError(errorCode, httpResponseCode, errorPage, additionalInfo) {
DoUploadFileCountChange();
switch (errorCode) {
case 9: // User
case 12: // Script
case 13: // Trial
case 18: DoUploadCallback('D'); break; // Event
default: DoUploadCallback(status);
}
}
function DoAfterUpload() {
DoUploadCallback(status);
}
In the past two days I have had two (that I know of) instances where the uploaded files got messed up partway through the upload. The users (two different ones) both tell me they have not gotten any errors while uploading. What I am seeing as an end result is that I have proper matching small, medium, and large files on Amazon then suddenly I have a large file in the small directory, a small image in the medium directory, a medium image in the large directory. The large sized small image is a different image than the the small sized medium or medium sized large. All the files after that point are messed up and sometimes missing completely. I know this is a sketchy description of the problem at best but is there something I am obviously doing wrong in the javascript above, or something I can be checking to make sure that this actually raises an exception if it happens again? The only reason I know it has happened in these two cases is that I have a process that is pulling all the large images down to my local servers and one of the large images was missing in both of these cases. This generated and logged an error on my internal code. I recognize that it is possible the same thing has happened elsewhere but I'm not missing a large image so I don't know about it. I will be updating the code to 8.0.32 within a few days but don't see anything in your changes list that might address this. Any guidance would be greatly appreciated. I have attached a screen shot that shows the photos right as they start going bad. First row was ok, all the following have images messed up. Thanks, Mike Edited by user Wednesday, March 6, 2013 1:50:47 PM(UTC)
| Reason: Added screen shot mmount attached the following image(s):
|