2011-12-29 5 views
5

푸른 색 바탕에 파일을 직접 업로드하는 데 문제가 있습니다. 나는 아약스 호출을 사용하여 청크에 blob을 업로드하기 위해 ashx 처리기에 게시물 요청을 보냅니다. 내가 겪고있는 문제는 핸들러가 아약스 게시물에서 보내지는 파일 챈크를받지 못한다는 것입니다.Azure로 업로드

나는 페이지가 방화범의 요청에 따라보고에서 올바르게 게시물을 수신 볼 수

---------------------- ------- 265001916915724 내용 - 처분 : form-data; > name = "Slice"; 파일 이름 = "덩어리"콘텐츠 형식 : 응용 프로그램/octet-stream을

내가 핸들러의 입력 스트림을 발견 요청에서 추가 바이트를 포함하여 filechunk을 가지고 있습니다. 필자는 입력 스트림에서 파일 덩어리 크기 만 읽으려고했지만 파일이 손상되었습니다.

나는 http://code.msdn.microsoft.com/windowsazure/Silverlight-Azure-Blob-3b773e26에서 영감을 얻었으므로 단순히 MVC3을 표준 aspx로 변환했습니다.

여기에 저를 도울 수 아무것도

var sendFile = function (blockLength) { 
var start = 0, 
    end = Math.min(blockLength, uploader.file.size), 
    incrimentalIdentifier = 1, 
    retryCount = 0, 
    sendNextChunk, fileChunk; 
uploader.displayStatusMessage(); 
sendNextChunk = function() { 
    fileChunk = new FormData(); 
    uploader.renderProgress(incrimentalIdentifier); 
    if (uploader.file.slice) { 
     fileChunk.append('Slice', uploader.file.slice(start, end)); 
    } 
    else if (uploader.file.webkitSlice) { 
     fileChunk.append('Slice', uploader.file.webkitSlice(start, end)); 
    } 
    else if (uploader.file.mozSlice) { 
     fileChunk.append('Slice', uploader.file.mozSlice(start, end)); 
    } 
    else { 
     uploader.displayLabel(operationType.UNSUPPORTED_BROWSER); 
     return; 
    } 
    var testcode = 'http://localhost:56307/handler1.ashx?create=0&blockid=' + incrimentalIdentifier + '&filename=' + uploader.file.name + '&totalBlocks=' + uploader.totalBlocks; 
    jqxhr = $.ajax({ 
     async: true,   
     url: testcode, 
     data: fileChunk, 
     contentType: false, 
     processData:false, 
     dataType: 'text json',   
     type: 'POST', 
     error: function (request, error) { 
      if (error !== 'abort' && retryCount < maxRetries) { 
       ++retryCount; 
       setTimeout(sendNextChunk, retryAfterSeconds * 1000); 
      } 

      if (error === 'abort') { 
       uploader.displayLabel(operationType.CANCELLED); 
       uploader.resetControls(); 
       uploader = null; 
      } 
      else { 
       if (retryCount === maxRetries) { 
        uploader.uploadError(request.responseText); 
        uploader.resetControls(); 
        uploader = null; 
       } 
       else { 
        uploader.displayLabel(operationType.RESUME_UPLOAD); 
       } 
      } 

      return; 
     }, 
     success: function (notice) { 
      if (notice.error || notice.isLastBlock) { 
       uploader.renderProgress(uploader.totalBlocks + 1); 
       uploader.displayStatusMessage(notice.message); 
       uploader.resetControls(); 
       uploader = null; 
       return; 
      } 

      ++incrimentalIdentifier; 
      start = (incrimentalIdentifier - 1) * blockLength; 
      end = Math.min(incrimentalIdentifier * blockLength, uploader.file.size); 
      retryCount = 0; 
      sendNextChunk(); 
     } 
    }); 
}; 

정말 고마워요, 영문 페이지에 파일 청크를 보낼 아약스를 사용하여 호출입니다.

답변

0

내 webform이 켜졌습니다. 입력 파일 태그에 enctype = "multipart/form-data"속성이 없습니다.

0

의도적으로 ASPX입니까? http://localhost:56307/handler1. ashx? create = 0 & blockid?

+0

aspx 페이지 대신 제네릭 처리기를 사용하려고했지만 두 옵션 모두 여전히 보내지는 filechunk를 읽을 수 없으며 Request.Files는 여전히 비어 있습니다. – Zephon

관련 문제