Exemplo n.º 1
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            if (!CheckAuthorization())
            {
                return(null);
            }

            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("encrypt", (!Encryption).ToString());
            args.Add("expirationUnit", ExpirationUnit.ToString());
            args.Add("expirationLength", ExpirationLength.ToString());
            args.Add("saveKey", (!Encryption).ToString());
            args.Add("keySize", "256");
            args.Add("blockSize", "128");
            args.Add("genDeletionKey", GenerateDeletionKey.ToString());

            UploadResult result = SendRequestFile(APIUrl, stream, fileName, "file", args, teknik.GetAuthHeaders());

            if (result.IsSuccess)
            {
                TeknikUploadResponseWrapper response = JsonConvert.DeserializeObject <TeknikUploadResponseWrapper>(result.Response);

                if (response.Result != null && response.Error == null)
                {
                    result.URL = response.Result.Url;
                }
            }

            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates the specified name.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="guestsCanAdd">if set to <c>true</c> [guests can add].</param>
 /// <param name="guestsCanComment">if set to <c>true</c> [guests can comment].</param>
 /// <param name="guestsCanDelete">if set to <c>true</c> [guests can delete].</param>
 /// <param name="expirationLength">Length of the expiration.</param>
 /// <param name="password">The password.</param>
 /// <param name="adminPassword">The admin password.</param>
 /// <param name="premiumCode">The premium code.</param>
 /// <returns></returns>
 public static Drop Create(string name, bool guestsCanAdd, bool guestsCanComment, bool guestsCanDelete, ExpirationLength expirationLength, string password, string adminPassword, string premiumCode)
 {
     return ServiceProxy.Instance.CreateDrop(name, guestsCanAdd, guestsCanComment, guestsCanDelete, expirationLength, password, adminPassword, premiumCode);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates the drop.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="guestsCanAdd">if set to <c>true</c> [guests can add].</param>
 /// <param name="guestsCanComment">if set to <c>true</c> [guests can comment].</param>
 /// <param name="guestsCanDelete">if set to <c>true</c> [guests can delete].</param>
 /// <param name="expirationLength">Length of the expiration.</param>
 /// <param name="password">The password.</param>
 /// <param name="adminPassword">The admin password.</param>
 /// <param name="premiumCode">The premium code.</param>
 /// <returns></returns>
 public Drop CreateDrop(string name, bool guestsCanAdd, bool guestsCanComment, bool guestsCanDelete, ExpirationLength expirationLength, string password, string adminPassword, string premiumCode)
 {
     return this.ServiceAdapter.CreateDrop(name, guestsCanAdd, guestsCanComment, guestsCanDelete, expirationLength, password, adminPassword, premiumCode);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a Drop.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="guestsCanAdd">if set to <c>true</c> [guests can add].</param>
        /// <param name="guestsCanComment">if set to <c>true</c> [guests can comment].</param>
        /// <param name="guestsCanDelete">if set to <c>true</c> [guests can delete].</param>
        /// <param name="expirationLength">Length of the expiration.</param>
        /// <param name="password">The password.</param>
        /// <param name="adminPassword">The admin password.</param>
        /// <param name="premiumCode">The premium code.</param>
        /// <returns></returns>
        public Drop CreateDrop(string name, bool guestsCanAdd, bool guestsCanComment, bool guestsCanDelete, ExpirationLength expirationLength, string password, string adminPassword, string premiumCode)
        {
            Drop d = null;

            NameValueCollection parameters = new NameValueCollection();

            parameters.Add("name", name);
            parameters.Add("guests_can_add", guestsCanAdd.ToString());
            parameters.Add("guests_can_comment", guestsCanComment.ToString());
            parameters.Add("guests_can_delete", guestsCanDelete.ToString());
            parameters.Add("expiration_length", this.MapExpirationLength(expirationLength));
            parameters.Add("password", password);
            parameters.Add("admin_password", adminPassword);
            parameters.Add("premium_code", premiumCode);

            HttpWebRequest request = this.CreatePostRequest(this.CreateDropUrl(string.Empty), parameters);
            CompleteRequest(request, delegate(HttpWebResponse response)
            {
                ReadResponse(response, (XmlDocument doc) => d = this.CreateAndMapDrop(doc));
            });

            return d;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Maps the length of the expiration.
        /// </summary>
        /// <param name="expirationLength">Length of the expiration.</param>
        /// <returns></returns>
        protected string MapExpirationLength(ExpirationLength expirationLength)
        {
            switch (expirationLength)
            {
                case ExpirationLength.OneDayFromLastView:
                    return "1_DAY_FROM_LAST_VIEW";
                case ExpirationLength.OneWeekFromLastView:
                    return "1_WEEK_FROM_LAST_VIEW";
                case ExpirationLength.OneMonthFromLastView:
                    return "1_MONTH_FROM_LAST_VIEW";
                case ExpirationLength.OneYearFromLastView:
                    return "1_YEAR_FROM_LAST_VIEW";
                case ExpirationLength.OneDayFromNow:
                    return "1_DAY_FROM_NOW";
                case ExpirationLength.OneWeekFromNow:
                    return "1_WEEK_FROM_NOW";
                case ExpirationLength.OneMonthFromNow:
                    return "1_MONTH_FROM_NOW";
                case ExpirationLength.OneYearFromNow:
                    return "1_YEAR_FROM_NOW";
            }

            return string.Empty;
        }