public ThreeSharpFormSample() { InitializeComponent(); this.transfers = new BindingList<Transfer>(); this.dataGridViewStatistics.DataSource = transfers; bindStatisticsDelegate = new BindStatisticsDelegate(this.BindStatistics); listBucketDelegate = new ListBucketDelegate(this.ListBucket); listFolderDelegate = new ListFolderDelegate(this.ListFolder); uploadFileDelegate = new UploadFileDelegate(this.UploadFile); downloadFileDelegate = new DownloadFileDelegate(this.DownloadFile); this.basePath = "C:\\"; config = new ThreeSharpConfig(); config.AwsAccessKeyID = Properties.Settings.Default.AwsAccessKeyID; config.AwsSecretAccessKey = Properties.Settings.Default.AwsSecretAccessKey; config.ConnectionLimit = 40; config.IsSecure = true; // It is necessary to use the SUBDOMAIN CallingFormat for accessing EU buckets config.Format = CallingFormat.SUBDOMAIN; this.service = new ThreeSharpQuery(config); }
public S3Connection(String awsAccessKeyId, String awsSecretAccessKey) { m_config = new ThreeSharpConfig(); m_config.AwsAccessKeyID = awsAccessKeyId; m_config.AwsSecretAccessKey = awsSecretAccessKey; m_config.IsSecure = false; m_service = new ThreeSharpQuery(m_config); }
protected void Page_Load(object sender, EventArgs e) { SlickUpload1.HideDuringUploadElements = "fileSelectText," + uploadButton.ClientID; ThreeSharpConfig cfg = new ThreeSharpConfig(); cfg.AwsAccessKeyID = ConfigurationManager.AppSettings["awsAccessKeyId"]; cfg.AwsSecretAccessKey = ConfigurationManager.AppSettings["awsSecretAccessKey"]; _q = new ThreeSharpQuery(cfg); }
public S3BinaryRepository() { ThreeSharpConfig config; config = new ThreeSharpConfig(); config.AwsAccessKeyID = S3Storage.AccessKey; config.AwsSecretAccessKey = S3Storage.SecretAccessKey; config.ConnectionLimit = 40; config.IsSecure = true; _service = new ThreeSharpQuery(config); }
public BinaryRepository(string accessKey, string secretKey, string bucketName) { AccessKey = accessKey; SecretKey = secretKey; BucketName = bucketName; ThreeSharpConfig config; config = new ThreeSharpConfig(); config.AwsAccessKeyID = accessKey; config.AwsSecretAccessKey = secretKey; config.ConnectionLimit = 40; config.IsSecure = true; config.Format = CallingFormat.SUBDOMAIN; _service = new ThreeSharpQuery(config); }
public void CreateTileset() { HttpWebRequest oWebRequest = (HttpWebRequest)WebRequest.Create(GetOriginalUrl()); HttpWebResponse oWebResponse = (HttpWebResponse)oWebRequest.GetResponse(); Stream oWebStream = oWebResponse.GetResponseStream(); Image oImage = Bitmap.FromStream(oWebStream); ThreeSharpConfig config; IThreeSharp service; config = new ThreeSharpConfig(); config.AwsAccessKeyID = S3Storage.AccessKey; config.AwsSecretAccessKey = S3Storage.SecretAccessKey; config.ConnectionLimit = 40; config.IsSecure = true; // It is necessary to use the SUBDOMAIN CallingFormat for accessing EU buckets config.Format = CallingFormat.SUBDOMAIN; service = new ThreeSharpQuery(config); double iZoomLevel = 0; double iMaxDimension = Math.Max(oImage.Width, oImage.Height); int iTileSize = Convert.ToInt32(iMaxDimension); while (iTileSize > 359) { iZoomLevel++; iTileSize = Convert.ToInt32(iMaxDimension / Math.Pow(2, iZoomLevel)); } ZoomLevels = Convert.ToInt32(iZoomLevel); TileSize = iTileSize; int iImageSize = Convert.ToInt32(iMaxDimension); Bitmap oBaseImage = ImageManipulator.CenterImage(oImage as Bitmap, iImageSize, iImageSize); while (iZoomLevel >= 0) { iImageSize = Convert.ToInt32(iTileSize * Math.Pow(2, iZoomLevel)); using (Bitmap oZoomedImage = ImageManipulator.Resize(oBaseImage, iImageSize, iImageSize)) { List<List<Bitmap>> oTiles = ImageManipulator.CreateTiles(oZoomedImage, iTileSize); for (int i = 0; i < oTiles.Count; i++) { for (int j = 0; j < oTiles[i].Count; j++) { bool bUploaded = false; int tryCount = 0; while (bUploaded == false && tryCount < 3) { try { using (MemoryStream oStream = new MemoryStream()) { oTiles[i][j].Save(oStream, System.Drawing.Imaging.ImageFormat.Png); oStream.Position = 0; UploadImage( service, oStream, string.Format("Tile_{0}_{1}_{2}_{3}", j, i, iZoomLevel, mStorageKey), "image/png" ); bUploaded = true; } } catch (ThreeSharpException oException) { tryCount++; if (tryCount > 3) { throw new Exception("Failed to upload tile on third attempt.", oException); } } } } } } iZoomLevel--; } }
private void UploadBaseImages(Stream oStream) { ThreeSharpConfig config; IThreeSharp service; config = new ThreeSharpConfig(); config.AwsAccessKeyID = S3Storage.AccessKey; config.AwsSecretAccessKey = S3Storage.SecretAccessKey; config.ConnectionLimit = 40; config.IsSecure = true; // It is necessary to use the SUBDOMAIN CallingFormat for accessing EU buckets config.Format = CallingFormat.SUBDOMAIN; service = new ThreeSharpQuery(config); string strSquareKey = "Square_" + mStorageKey; string strThumbKey = "Thumb_" + mStorageKey; string strLargeThumbKey = "LargeThumb_" + mStorageKey; string strPreviewKey = "Preview_" + mStorageKey; using (System.Drawing.Image oImage = Bitmap.FromStream(oStream, true, true)) { using (System.Drawing.Image oSquare = ImageManipulator.ResizeAndCrop(oImage as Bitmap, 80, 80)) { using (MemoryStream oMemoryStream = new MemoryStream()) { oSquare.Save(oMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); oMemoryStream.Position = 0; UploadImage(service, oMemoryStream, strSquareKey, "image/jpeg"); } } using (System.Drawing.Image oThumb = ImageManipulator.FitToRectangle(oImage as Bitmap, 100, 100)) { using (MemoryStream oMemoryStream = new MemoryStream()) { oThumb.Save(oMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); oMemoryStream.Position = 0; UploadImage(service, oMemoryStream, strThumbKey, "image/jpeg"); } } using (System.Drawing.Image oLargeThumb = ImageManipulator.FitToRectangle(oImage as Bitmap, 200, 200)) { using (MemoryStream oMemoryStream = new MemoryStream()) { oLargeThumb.Save(oMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); oMemoryStream.Position = 0; UploadImage(service, oMemoryStream, strLargeThumbKey, "image/jpeg"); } } using (System.Drawing.Image oLargeThumb = ImageManipulator.FitToRectangle(oImage as Bitmap, 560, 560)) { using (MemoryStream oMemoryStream = new MemoryStream()) { oLargeThumb.Save(oMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); oMemoryStream.Position = 0; UploadImage(service, oMemoryStream, strPreviewKey, "image/jpeg"); } } } oStream.Position = 0; UploadImage(service, oStream, mStorageKey, ThreeSharpUtils.ConvertExtensionToMimeType(Path.GetExtension(mStorageKey))); ImageSet = 1; // this is the version of the imageset if you change any of the above sizes names or add new ones // this needs to be updated. }