Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new access from a serialized string.
        /// An access contains info about the satellite-address, the passphrase and the API-Key.
        /// </summary>
        /// <param name="accessGrant">The serialized access grant</param>
        /// <param name="config">The configuration (optional)</param>
        public Access(string accessGrant, Config config = null)
        {
            Init();

            try
            {
                using (var accessResult = SWIG.storj_uplink.uplink_parse_access(accessGrant))
                {
                    if (accessResult.error != null && !string.IsNullOrEmpty(accessResult.error.message))
                    {
                        throw new ArgumentException(accessResult.error.message);
                    }

                    _access = accessResult.access;

                    var uplinkConfigSWIG = GetUplinkConfig(config);
                    using (var projectResult = SWIG.storj_uplink.uplink_config_open_project(uplinkConfigSWIG, _access))
                    {
                        if (projectResult.error != null && !string.IsNullOrEmpty(projectResult.error.message))
                        {
                            throw new ArgumentException(projectResult.error.message);
                        }

                        _project = projectResult.project;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new access based on the satellite-adress, the API-key and the secret passphrase and by using a specific config
        /// </summary>
        /// <param name="satelliteAddress">The satellite address</param>
        /// <param name="apiKey">The API-key</param>
        /// <param name="secret">The passphrase</param>
        /// <param name="config">The configuration</param>
        public Access(string satelliteAddress, string apiKey, string secret, Config config)
        {
            Init();

            try
            {
                var uplinkConfigSWIG = GetUplinkConfig();
                using (var accessResult = SWIG.storj_uplink.uplink_config_request_access_with_passphrase(uplinkConfigSWIG, satelliteAddress, apiKey, secret))
                {
                    if (accessResult.error != null && !string.IsNullOrEmpty(accessResult.error.message))
                    {
                        throw new ArgumentException(accessResult.error.message);
                    }

                    _access = accessResult.access;

                    using (var projectResult = SWIG.storj_uplink.uplink_open_project(_access))
                    {
                        if (projectResult.error != null && !string.IsNullOrEmpty(projectResult.error.message))
                        {
                            throw new ArgumentException(projectResult.error.message);
                        }

                        _project = projectResult.project;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Ejemplo n.º 3
0
        internal static Bucket FromSWIG(SWIG.UplinkBucket original, SWIG.UplinkProject projectRef, SWIG.UplinkBucketResult bucketResult = null)
        {
            Bucket ret = new Bucket();

            ret._bucketRef       = original;
            ret._bucketResultRef = bucketResult;
            ret._projectRef      = projectRef;

            return(ret);
        }
Ejemplo n.º 4
0
 public void Dispose()
 {
     if (_project != null)
     {
         using (SWIG.UplinkError closeError = SWIG.storj_uplink.uplink_close_project(_project))
         {
             _project.Dispose();
             _project = null;
         }
     }
 }
Ejemplo n.º 5
0
        internal static Bucket FromSWIG(SWIG.UplinkBucket original, SWIG.UplinkProject projectRef, SWIG.UplinkBucketResult bucketResult = null)
        {
            Bucket ret = new Bucket();

            ret._bucketRef       = original;
            ret._bucketResultRef = bucketResult;
            ret._projectRef      = projectRef;
            ret._name            = original.name;

            //Temporary to fix a calloc-issue. Should already be fixed - so just to be safe.
            try
            {
                ret._created = DateTimeOffset.FromUnixTimeSeconds(original.created).ToLocalTime().DateTime;
            }
            catch
            {
                ret._created = DateTime.Now;
            }

            return(ret);
        }
Ejemplo n.º 6
0
        internal Access(SWIG.UplinkAccess access)
        {
            Init();

            try
            {
                _access = access;

                var uplinkConfigSWIG = GetUplinkConfig();
                using (var projectResult = SWIG.storj_uplink.uplink_config_open_project(uplinkConfigSWIG, _access))
                {
                    if (projectResult.error != null && !string.IsNullOrEmpty(projectResult.error.message))
                    {
                        throw new ArgumentException(projectResult.error.message);
                    }

                    _project = projectResult.project;
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }