private NGLib.COMPONENTS.FILE.STORAGE.SwiftFileStorage GetswiftStore() { if (DatainvoiceSwiftStore != null) { return(DatainvoiceSwiftStore); } NGLib.COMPONENTS.FILE.STORAGE.SwiftFileStorage swift = new NGLib.COMPONENTS.FILE.STORAGE.SwiftFileStorage(null); //swift.authUser = "******"; //swift.authPassword = "******"; ////swift.authToken = "eb6f7bac33654389b98b8cfa2a58a2c8"; // token obtenu via authenticate //swift.serviceUrl = "https://storage.gra1.cloud.ovh.net/v1/"; //swift.authUrl = "https://auth.cloud.ovh.net/v2.0/"; //swift.Account = "AUTH_ffa7db5e3ea142659421c00897aa0cf1"; //swift.tenantName = "3400672520369917"; swift.authUser = "******"; swift.authPassword = "******"; //swift.authToken = "eb6f7bac33654389b98b8cfa2a58a2c8"; // token obtenu via authenticate swift.serviceUrl = "https://storage.gra3.cloud.ovh.net/v1/"; swift.authUrl = "https://auth.cloud.ovh.net/v2.0/"; swift.Account = "AUTH_047b336dc7614317beff6f17bdaa316b"; swift.tenantName = "7175350708785552"; swift.Open(); Console.WriteLine("IsAuthenticated " + swift.IsAuthenticated()); Console.WriteLine("COPROP_Test exist " + swift.GetObjectList("COPROP_Test2")); DatainvoiceSwiftStore = swift; return(swift); }
public byte[] DownloadFile(Invoice invoice) { try { if (string.IsNullOrEmpty(invoice.IDFile)) { return(null); } NGLib.COMPONENTS.FILE.STORAGE.SwiftFileStorage storer = GetswiftStore(); byte[] fileBytes = storer.Download("invc" + invoice.IDAccount.ToString(), invoice.IDFile); //Stream stream = new MemoryStream(fileBytes); return(fileBytes); } catch (Exception ex) { throw new Exception("DownloadFile Invoice " + ex.Message, ex); } }
public bool DeleteFile(Invoice invoice) { try { if (string.IsNullOrEmpty(invoice.IDFile)) { return(false); } NGLib.COMPONENTS.FILE.STORAGE.SwiftFileStorage storer = GetswiftStore(); if (storer.Delete(invoice.IDAccount.ToString(), invoice.IDFile)) { invoice["IDFile"] = null; base.SaveBubble(invoice); return(true); } return(false); } catch (Exception ex) { throw new Exception("DeleteFile Invoice " + ex.Message, ex); } }
public string AddFile(Invoice invoice, System.IO.Stream fileStream) { try { string IDLocalFile = string.Empty; byte[] fileBinary = new byte[fileStream.Length]; fileStream.Read(fileBinary, 0, (int)fileStream.Length); NGLib.COMPONENTS.FILE.STORAGE.SwiftFileStorage storer = GetswiftStore(); string conteneurNameTest = "invc" + invoice.IDAccount.ToString(); if (!storer.ContainerExists(conteneurNameTest)) { storer.CreateContainer(conteneurNameTest); } IDLocalFile = storer.Upload("invc" + invoice.IDAccount.ToString(), fileBinary); invoice.IDFile = IDLocalFile; base.SaveBubble(invoice); return(IDLocalFile); } catch (Exception ex) { throw new Exception("AddFile Invoice " + ex.Message, ex); } }