2016-06-16 8 views
1

Alamofire upload 코드에는 namefileName 필드가 있습니다. 내 봄 서버에서Alamofire 업로드 "이름"매개 변수

Alamofire.upload(
        .POST, 
        "http://192.168.1.241:8080/file/user", 
        multipartFormData: { multipartFormData in 
         multipartFormData.appendBodyPart(data: imageData, name: "file", fileName: "file", mimeType: "image/jpeg") 
        }, 
        encodingCompletion: { encodingResult in 
         switch encodingResult { 
         case .Success(let upload, _, _): 
          upload.progress { bytesWritten, totalBytesWritten, totalBytesExpectedToWrite in 
           dispatch_async(dispatch_get_main_queue()) { 
            let percent = (Float(totalBytesWritten)/Float(totalBytesExpectedToWrite)) 
            //progress(percent: percent) 
            print(percent) 
           } 
          } 
          upload.responseJSON { response in 
           debugPrint(response) 
          } 
         case .Failure(let encodingError): 
          debugPrint(encodingError) 
         } 
        } 
        ) 

나는 @RequestParam("file") MultipartFile file를 찾고 내가 filename 설정 되었기 때문에이 일을 가져올 수 없습니다. 하지만 분명히 fileName"file"으로 설정해야했습니다.

name의 목적은 요청 매개 변수 매핑에 사용되지 않는 것일 수 있습니다. 비디오 : "파일 이름"단지에만 lastPathComponentString의 형식 (예 : (www.mysite.com/myvideo.mp4 예)

답변

1

는 "파일"에 대한 당신의 파일의 전체 NSURL 속성을 의미 .mp4)

+0

파일의 NSData를 전달할 때 파일의 NSURL 속성이 필요한 이유는 무엇입니까? – Alan

+0

NSData는 파일 데이터 만 포함 할 때 NSURL 속성을 일부 매개 변수로 구성 할 수 있으므로 소스는 MultipartFormData의 결과로 요청을 잘 구분합니다. Alamofire는 NSMutableURLRequest를 기반으로하는 복잡한 프레임 워크입니다. –

관련 문제