0
우리 상황에서는 Microsoft Dynamics NAV를 사용하여 SQL 데이터베이스에 파일을 저장합니다. 그런 다음이 BLOB/이미지 데이터를 가져 와서 base64 문자열로 변환하고 SOAP 서비스로 전송 한 다음 다시 파일로 저장합니다. 결과 파일은 항상 원본보다 훨씬 큽니다. 파일 크기는 120KB, 248KB, 504KB, 1016KB, 2040KB 등의 고유 한 패턴을 따르는 것 같습니다.SQL 이미지로 저장하고 기본 64 문자열로 전송 한 후의 파일 크기
예 :23.669.715 바이트 파일을 저장하면 33.546.240 바이트 파일 이 경로를 따른 후에.
C# 코드는 파일 저장 :
string fileData = string.Empty;
WebshopMgt webService = Helpers.WebServices.GetWebshopService();
try
{
webService.GetDocumentData(navDocument.IntegrationID, ref fileData);
}
catch (Exception ex)
{
Log.Error(String.Format("Error retrieving document data for NAV Document '{0}'.", navDocument.IntegrationID), ex);
return Status.SetStatus(navDocument.IntegrationID, syncId, SyncStatus.Failed, ex.Message);
}
try
{
byte[] buffer = Convert.FromBase64String(fileData);
FileStream fileStream = File.Create(filePath);
fileStream.Write(buffer, 0, buffer.Length);
fileStream.Close();
}
catch (Exception ex)
{
Log.Error(String.Format("Error saving document data for NAV Document '{0}'.", navDocument.IntegrationID), ex);
return Status.SetStatus(navDocument.IntegrationID, syncId, SyncStatus.Failed, ex.Message);
}
이 코드는 [확인] (http://msdn.microsoft.com/en-us/library/system.convert.frombase64string%28v=vs.110%29.aspx)이므로 문제가있는 것 같습니다. 데이터 저장 또는 검색. – CodeCaster
디버깅하는 동안 패턴이 보입니다. 모든 문자열에는 'A'가 많이 쌓여 있습니다. 일부 문자열에는 끝에 수만 개의 A가 있습니다. A ==로 끝나는 모두. –
거의 모든 기본 64 구현에서'A = 0'을 감안할 때 콘텐츠 길이는 저장하지 않고 실제 전체 버퍼는 저장하지 않을 수도 있습니다. 1,024 바이트의 버퍼를 사용 중이며 내용의 길이가 1 바이트 만이라면 1023의 '0'을 저장하는 것으로 보입니다. – CodeCaster