Esempio n. 1
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            if (string.IsNullOrEmpty(Config.UserAPIKey))
            {
                Errors.Add("Missing API key. Set one in destination settings.");
                return(null);
            }

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

            arguments.Add("apikey", Config.UserAPIKey);
            UploadResult result = UploadData(stream, uploadUrl, fileName, "file", arguments);

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

                if (response.success)
                {
                    result.URL = responseUrl + response.files[0].url;
                }
                else
                {
                    foreach (string e in response.errors)
                    {
                        Errors.Add(e);
                    }
                }
            }

            return(result);
        }
Esempio n. 2
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            Dictionary <string, string> arguments = new Dictionary <string, string>();

            arguments.Add("api_key", Config.UserAPIKey);
            UploadResult result = UploadData(stream, uploadUrl, fileName, "file", arguments, method: HttpMethod.PUT);

            if (result.Response == null)
            {
                Errors.Add("Upload failed for unknown reason. Check your API key.");
                return(result);
            }

            LambdaResponse response = JsonConvert.DeserializeObject <LambdaResponse>(result.Response);

            if (result.IsSuccess)
            {
                result.URL = Config.UploadURL + response.url;
            }
            else
            {
                foreach (string e in response.errors)
                {
                    Errors.Add(e);
                }
            }

            return(result);
        }
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public dynamic FunctionHandler(LambdaRequest <MessageRequest> request, ILambdaContext context)
        {
            if (request.headers.ContainsKey("Authorization"))
            {
                if (request.headers["Authorization"] != Environment.GetEnvironmentVariable("AUTH_KEY"))
                {
                    throw new UnauthorizedAccessException();
                }
            }
            else
            {
                throw new UnauthorizedAccessException();
            }

            try
            {
                IFuncMessageSender funcMessageService = (IFuncMessageSender)Intgr.DI.Injection.DIServiceProvider.GetService(typeof(IFuncMessageSender));
                string             messageId          = funcMessageService.SendMessage(request.body);
                return(LambdaResponse.GetSuccessResponse(messageId));
            }
            catch (Exception e)
            {
                return(LambdaResponse.GetFailResponse(e));
            }
        }
        public Task <ILambdaResponse <string> > HandleAsync(int reservationId, ILambdaContext context)
        {
            var sizedId = reservationId.ToString().PadLeft(11, '0');

            return(Task.FromResult(LambdaResponse <string> .Ok(sizedId)));
        }