Changeset 11903 for extensions/PiwigoLib/PiwigoLib/Service
- Timestamp:
- Aug 3, 2011, 5:48:31 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PiwigoLib/PiwigoLib/Service/PwgImagesService.cs
r11890 r11903 48 48 return returnValue; 49 49 } 50 50 51 51 public PwgImageAdded addImageByMultiPartForm(FileInfo fileImage, Int32? imageId, Int32? categoryId, String imageName, String imageAuthor, String imageComment, Int32? imageLevel, List<PwgTag> imageTags) 52 52 { … … 89 89 try 90 90 { 91 String file Guid = uploadImageByChunk(lowResFile, PwgFileTypeEnum.LowRes);92 String thunb Guid = uploadImageByChunk(thumbFile, PwgFileTypeEnum.Thumb);93 String Highres Guid = uploadImageByChunk(highResFile, PwgFileTypeEnum.HighDef);94 String image Guid = (highResFile != null ? HighresGuid : fileGuid); //Guid.NewGuid().ToString();91 String fileMd5sum = uploadImageByChunk(lowResFile, PwgFileTypeEnum.LowRes, null); 92 String thunbMd5sum = uploadImageByChunk(thumbFile, PwgFileTypeEnum.Thumb, fileMd5sum); 93 String HighresMd5sum = uploadImageByChunk(highResFile, PwgFileTypeEnum.HighDef, fileMd5sum); 94 String imageMd5sum = fileMd5sum; //(highResFile != null ? HighresMd5sum : fileMd5sum); //Md5sum.NewMd5sum().ToString(); 95 95 String imageFilename = (highResFile != null ? highResFile.Name : lowResFile.Name); 96 96 97 PwgBaseProxyReponse response = PwgImagesProxy.pwg_images_add( file Guid, thunbGuid, HighresGuid,98 image Guid, imageFilename, imageName, imageAuthor, creationDate,97 PwgBaseProxyReponse response = PwgImagesProxy.pwg_images_add( fileMd5sum, thunbMd5sum, HighresMd5sum, 98 imageMd5sum, imageFilename, imageName, imageAuthor, creationDate, 99 99 authorComment, lstCategories, lstTags, confidentLevel); 100 100 … … 124 124 } 125 125 126 public String uploadImageByChunk(FileInfo imageFile, PwgFileTypeEnum fileType )126 public String uploadImageByChunk(FileInfo imageFile, PwgFileTypeEnum fileType, String InitialMd5sum) 127 127 { 128 128 byte[] buffer = new byte[5000]; 129 string str Guid= String.Empty; ;129 string strMd5sum = String.Empty; ; 130 130 int read; 131 131 int chunkNumber = 1; … … 136 136 { 137 137 FileStream fs = File.OpenRead(imageFile.FullName); 138 strGuid = Com.Piwigo.Lib.Proxy.Helper.PwgBase64Helper.GetphpMd5Sum(fs); 138 strMd5sum = Com.Piwigo.Lib.Proxy.Helper.PwgBase64Helper.GetphpMd5Sum(fs); 139 // if not checksum was provide we use the one computed for transfert 140 if (String.IsNullOrWhiteSpace(InitialMd5sum)) 141 { 142 InitialMd5sum = strMd5sum; 143 } 139 144 140 145 fs.Seek(0, SeekOrigin.Begin); 141 while ((read = fs.Read(buffer, 0, buffer.Length)) > 0) 142 { 143 String strB64Data = Com.Piwigo.Lib.Proxy.Helper.PwgBase64Helper.base64Encode(buffer); 144 PwgBaseProxyReponse response = PwgImagesProxy.pwg_images_addChunk(strB64Data, strGuid, fileType, chunkNumber); 146 while ((read = fs.Read(buffer, 0, 5000)) > 0) 147 { 148 byte[] truncBuffer; 149 // si on est arriver àla fin du fichier et que le tableau fait moins de 50000 , on le tronque en le copiant 150 // sinon on recopie l'adresse 151 if (read < 5000) 152 { 153 truncBuffer = new Byte[read]; 154 Array.Copy(buffer, truncBuffer, read); 155 } 156 else 157 { 158 truncBuffer = buffer; 159 } 160 161 String strB64Data = Com.Piwigo.Lib.Proxy.Helper.PwgBase64Helper.base64Encode(truncBuffer); 162 PwgBaseProxyReponse response = PwgImagesProxy.pwg_images_addChunk(strB64Data, InitialMd5sum, fileType, chunkNumber); 145 163 146 164 chunkNumber += 1; … … 163 181 else 164 182 { 165 str Guid= String.Empty;183 strMd5sum = String.Empty; 166 184 } 167 185 } … … 170 188 throw new PwgServiceException("uploadImageByChunk : a error is raised by proxy.", ex); 171 189 } 172 return str Guid;190 return strMd5sum; 173 191 } 174 192
Note: See TracChangeset
for help on using the changeset viewer.