Changeset 11903
- Timestamp:
- Aug 3, 2011, 5:48:31 PM (13 years ago)
- Location:
- extensions/PiwigoLib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PiwigoLib/PiwigoLib/Proxy/Helper/PwgBase64Helper.cs
r11890 r11903 12 12 try 13 13 { 14 string encodedData = Convert.ToBase64String(encData_byte); 14 String encodedData = String.Empty; 15 encodedData = Convert.ToBase64String(encData_byte); 16 //encodedData = Encoding.UTF8.GetString(encData_byte, 0, encData_byte.Length); 15 17 return encodedData; 16 18 } -
extensions/PiwigoLib/PiwigoLib/Proxy/PwgImagesProxy.cs
r11890 r11903 32 32 * */ 33 33 34 static internal PwgBaseProxyReponse pwg_images_add(String file Guid, String thunbGuid, String HighresGuid,35 String image Guid, String imageFilename, String imageName, String imageAuthor, DateTime creationDate,34 static internal PwgBaseProxyReponse pwg_images_add(String fileMd5sum, String thunbMd5sum, String HighresMd5sum, 35 String imageMd5sum, String imageFilename, String imageName, String imageAuthor, DateTime creationDate, 36 36 String authorComment,List<String> lstCategories, List<String> lstTags, PwgConfidentLevelEnum? confidentLevel) 37 37 { … … 42 42 data.Append("method=pwg.images.add"); 43 43 Boolean firstOcc = false; 44 PwgProxyReponseHelper.buildQueryFromValue<String>(file Guid, "file_sum", ref firstOcc, data);45 PwgProxyReponseHelper.buildQueryFromValue<String>(thunb Guid, "thumbnail_sum", ref firstOcc, data);46 PwgProxyReponseHelper.buildQueryFromValue<String>(Highres Guid, "high_sum", ref firstOcc, data);47 PwgProxyReponseHelper.buildQueryFromValue<String>(image Guid, "original_sum", ref firstOcc, data);44 PwgProxyReponseHelper.buildQueryFromValue<String>(fileMd5sum, "file_sum", ref firstOcc, data); 45 PwgProxyReponseHelper.buildQueryFromValue<String>(thunbMd5sum, "thumbnail_sum", ref firstOcc, data); 46 PwgProxyReponseHelper.buildQueryFromValue<String>(HighresMd5sum, "high_sum", ref firstOcc, data); 47 PwgProxyReponseHelper.buildQueryFromValue<String>(imageMd5sum, "original_sum", ref firstOcc, data); 48 48 PwgProxyReponseHelper.buildQueryFromValue<String>(imageFilename, "original_filename", ref firstOcc, data); 49 49 PwgProxyReponseHelper.buildQueryFromValue<String>(imageName, "name", ref firstOcc, data); -
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 -
extensions/PiwigoLib/TestPiwigoLib/Form1.cs
r11901 r11903 74 74 //lstCat = PwgServiceProvider.Instance.PwgCategoriesService.GetAdminListOfCategory(); 75 75 76 //FileInfo fiBig = new FileInfo("C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n.jpg");77 //FileInfo fiThumb = new FileInfo(MakeThumb(fiBig,"C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n_thum.jpg",64));78 //FileInfo fiLow = new FileInfo(MakeThumb(fiBig,"C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n_low.jpg",256));76 FileInfo fiBig = new FileInfo("C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n.jpg"); 77 FileInfo fiThumb = new FileInfo(MakeThumb(fiBig, "C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n_thum.jpg", 64)); 78 FileInfo fiLow = new FileInfo(MakeThumb(fiBig, "C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n_low.jpg", 256)); 79 79 80 FileInfo fiBig = new FileInfo("C:\\temp\\Oryx.jpg");81 FileInfo fiThumb = new FileInfo(MakeThumb(fiBig, "C:\\temp\\Oryx_thumb.jpg", 64));82 FileInfo fiLow = new FileInfo(MakeThumb(fiBig, "C:\\temp\\Oryx_low.jpg", 256));80 //FileInfo fiBig = new FileInfo("C:\\temp\\Oryx.jpg"); 81 //FileInfo fiThumb = new FileInfo(MakeThumb(fiBig, "C:\\temp\\Oryx_thumb.jpg", 64)); 82 //FileInfo fiLow = new FileInfo(MakeThumb(fiBig, "C:\\temp\\Oryx_low.jpg", 256)); 83 83 84 84 //PwgImageAdded imgAdd = PwgServiceProvider.Instance.PwgImagesService.addImageByMultiPartForm(fiBig, null, 1, "benoit", "byarl", "test upload", 0, new List<PwgTag>() { new PwgTag() { Name = "Benoit" }, new PwgTag() { Name = "Noé" } }); 85 rc = PwgServiceProvider.Instance.PwgImagesService.addImage(fiBig, fiLow, fiThumb, "Benoit", "bayral", DateTime.Now, "demo", n ull, null, PwgConfidentLevelEnum.All);85 rc = PwgServiceProvider.Instance.PwgImagesService.addImage(fiBig, fiLow, fiThumb, "Benoit", "bayral", DateTime.Now, "demo", new List<string>() { "1" }, new List<string>() { "Benoit" }, PwgConfidentLevelEnum.All); 86 86 //rc = PwgServiceProvider.Instance.PwgImagesService.DeleteImage(319, sess.SecurityToken); 87 87
Note: See TracChangeset
for help on using the changeset viewer.