public static void GoogleCloudPutUrl() { string bucketId = "my_bucket"; string putUrl = $"https://www.googleapis.com/upload/storage/v1/b/{bucketId}/o?uploadType=resumable"; Assert.AreEqual(putUrl, GoogleCloudStorage.PutUrl(bucketId)); }
/// <summary> /// Deletes the content from the external storage medium associated with the provider. /// </summary> /// <param name="file">The file.</param> public override void DeleteContent(BinaryFile file) { var bucketName = GetBucketName(); var accountKeyJson = GetServiceAccountKeyJson(); var googleObject = TranslateBinaryFileToGoogleObject(file); GoogleCloudStorage.DeleteObject(bucketName, accountKeyJson, false, googleObject.Name); }
/// <summary> /// Gets the assets from Google. /// </summary> /// <param name="assetStorageProvider">The asset storage provider.</param> /// <param name="directory">The directory.</param> /// <param name="assetTypeToList">The asset type to list.</param> /// <param name="allowRecursion">if set to <c>true</c> [allow recursion].</param> /// <returns></returns> private List <GoogleObject> GetObjectsFromGoogle(AssetStorageProvider assetStorageProvider, string directory, AssetType?assetTypeToList, bool allowRecursion) { var bucketName = GetBucketName(assetStorageProvider); var accountKeyJson = GetServiceAccountKeyJson(assetStorageProvider); return(GoogleCloudStorage.GetObjectsFromGoogle(bucketName, accountKeyJson, directory, assetTypeToList == AssetType.File, assetTypeToList == AssetType.Folder, allowRecursion)); }
private void UpdateGoogleCloudStorageStatus() { GoogleCloudStorage gcs = new GoogleCloudStorage(Config.GoogleCloudStorageOAuth2Info) { Bucket = Config.GoogleCloudStorageBucket, Domain = Config.GoogleCloudStorageDomain, Prefix = Config.GoogleCloudStorageObjectPrefix }; lblGoogleCloudStoragePathPreview.Text = gcs.GetPreviewURL(); }
public ImageController( IHostingEnvironment environment, IImageDAL imageDAL, GoogleCloudStorage cloudStorage, ApiAuthProvider authProvider ) { this.environment = environment; this.imageDAL = imageDAL; this.cloudStorage = cloudStorage; this.authProvider = authProvider; }
/// <summary> /// Deletes the asset. If Asset.Key is not provided then one is created using the RootFolder and Asset.Name. /// If Key is provided then it MUST use the full path, RootFolder is not used. /// </summary> /// <param name="assetStorageProvider"></param> /// <param name="asset">The asset.</param> /// <returns></returns> public override bool DeleteAsset(AssetStorageProvider assetStorageProvider, Asset asset) { var rootFolder = GetRootFolder(assetStorageProvider); FixKey(asset, rootFolder); var bucketName = GetBucketName(assetStorageProvider); var accountKeyJson = GetServiceAccountKeyJson(assetStorageProvider); var isFolder = asset.Type == AssetType.Folder; GoogleCloudStorage.DeleteObject(bucketName, accountKeyJson, isFolder, asset.Key); return(true); }
private void UpdateGoogleCloudStorageStatus() { GoogleCloudStorage gcs = new GoogleCloudStorage(Config.GoogleCloudStorageOAuth2Info) { Bucket = Config.GoogleCloudStorageBucket, Domain = Config.GoogleCloudStorageDomain, Prefix = Config.GoogleCloudStorageObjectPrefix, RemoveExtensionImage = Config.GoogleCloudStorageRemoveExtensionImage, RemoveExtensionText = Config.GoogleCloudStorageRemoveExtensionText, RemoveExtensionVideo = Config.GoogleCloudStorageRemoveExtensionVideo }; lblGoogleCloudStoragePathPreview.Text = gcs.GetPreviewURL(); }
static void Main(string[] args) { try { var googlecloud = new GoogleCloudStorage(); googlecloud.UploadData(new List<Class1> {new Class1() {Number = 2, String = "this is stirng"}}, "user1"); // new Program().Run().Wait(); } catch (AggregateException ex) { foreach (var err in ex.InnerExceptions) { Console.WriteLine("ERROR: " + err.Message); } } Console.ReadKey(); }
/// <summary> /// Gets the storage client. /// </summary> /// <returns></returns> private StorageClient GetStorageClient() { var accountKeyJson = GetServiceAccountKeyJson(); return(GoogleCloudStorage.GetStorageClient(accountKeyJson)); }
public ProductController(IProductServices productService, IFileUploadService fileUploadProcess, IOptions <GoogleCloudStorage> ggSetting) { this.productService = productService; this.fileUploadProcess = fileUploadProcess; this.ggSetting = ggSetting.Value; }
/// <summary> /// Returns a Google Storage Client using the attribute value settings. /// </summary> /// <param name="assetStorageProvider">The asset storage provider.</param> /// <returns></returns> private StorageClient GetStorageClient(AssetStorageProvider assetStorageProvider) { var accountKeyJson = GetServiceAccountKeyJson(assetStorageProvider); return(GoogleCloudStorage.GetStorageClient(accountKeyJson)); }