{"id":1706,"date":"2020-09-04T12:18:19","date_gmt":"2020-09-04T10:18:19","guid":{"rendered":"https:\/\/blog.besharp.it\/?p=1706"},"modified":"2021-03-18T16:22:29","modified_gmt":"2021-03-18T15:22:29","slug":"build-your-own-file-hosting-application-with-flutter-amplify-and-aws","status":"publish","type":"post","link":"https:\/\/blog.besharp.it\/build-your-own-file-hosting-application-with-flutter-amplify-and-aws\/","title":{"rendered":"Build your own mobile file hosting application with Flutter, Amplify, and AWS."},"content":{"rendered":"\n
Nowadays <\/span>Flutter<\/b> is becoming more and more recognized as a viable solution for making <\/span>mobile cross-platform<\/b> applications. Also, <\/span>AWS Amplify<\/b> is rapidly gaining the attention of the developer community as it makes it incredibly simple to setup applications <\/span>without worrying about backend infrastructure<\/b>, as the library does that for you.<\/span><\/p>\n\n\n\n Recently these two frameworks<\/span> joined forces<\/b> and the first release of <\/span>Amplify for Flutter<\/b> has been put online for developers to test out, with support for <\/span>Amazon Cognito<\/b>, <\/span>AWS S3,<\/b> and <\/span>Pinpoint<\/b> for logging.<\/span><\/p>\n\n\n\n Being eager to try it out, we created a Proof-of-Concept to show how well these libraries work together. Following we present how to develop an<\/span> AWS S3 powered<\/b> dropbox-like application with <\/span>Login<\/b> capabilities for <\/span>mobile devices<\/b>.<\/span><\/p>\n\n\n\n As a bonus, we also propose a simple configuration for managing your CI\/CD pipeline using <\/span>Travis CI. <\/b><\/p>\n\n\n\n The project can be created step by step following the guidelines provided or by directly downloading the entire solution from our <\/a><\/span>Github repository.<\/b><\/p>\n\n\n\n Let\u2019s get started!<\/p>\n\n\n\n In order to start developing applications in Flutter, some preliminary steps are required. You can follow the instructions provided below to set up your environment with all the required tools.<\/p>\n\n\n\n Before doing anything else be sure to create an appropriate account on AWS. Amplify needs access to the following cloud resources:<\/p>\n\n\n\n Therefore here is a simple AWS Policy with the set of rules you need in order to run Amplify:<\/p>\n\n\n\n Attach the policy to a user with <\/span>Programmatic Access<\/b>, <\/span>take note of the access and secret key<\/b>. <\/span>If you are not confident creating an AWS Policy on your own, check this link <\/a><\/span>or choose one of the many guides available online<\/span>.<\/span><\/p>\n\n\n\n A side note: it is advisable to remove the user as soon as Amplify has completed creating all the resources, to avoid leaving potential security breaches.<\/p>\n\n\n\n The next step is to configure AWS CLI on your computer. Download it<\/a> <\/span>choosing the appropriate installer for your OS. Install it and then in your terminal of choice type: <\/span>aws configure<\/strong>.<\/p>\n\n\n\n Use the <\/span>Access <\/b>and <\/span>Secret keys<\/b> you\u2019ve taken note of when prompted and the rest leave it as default.<\/span><\/p>\n\n\n\n With all this information filled up, you are now able to install Flutter and Amplify correctly.<\/p>\n\n\n\n We managed to install and launch Flutter without any difficulty by following this guide<\/a><\/span>. We chose MacOS and followed the instructions, setting up everything for working with Android Studio<\/a><\/span>, but you can use IntelliJ as well. After installing the framework, we connect a test phone and run <\/span>flutter devices<\/span> in the terminal to verify that it\u2019s found correctly.<\/span><\/p>\n\n\n\n Create a new <\/span>Flutter project<\/b> from the Android Studio menu and select <\/span>Flutter Application<\/b>. Compile the required options and let the IDE create the boilerplate for you.<\/span><\/p>\n\n\n\n Select your phone and <\/span>main.dart<\/b> file and press play like in figure:<\/span><\/p>\n\n\n\nSetup your environment<\/h1>\n\n\n\n
AWS CLI with a valid account for using Amplify<\/h2>\n\n\n\n
{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"VisualEditor0\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"appsync:*\",\n \"apigateway:POST\",\n \"apigateway:DELETE\",\n \"apigateway:PATCH\",\n \"apigateway:PUT\",\n \"cloudformation:CreateStack\",\n \"cloudformation:CreateStackSet\",\n \"cloudformation:DeleteStack\",\n \"cloudformation:DeleteStackSet\",\n \"cloudformation:DescribeStackEvents\",\n \"cloudformation:DescribeStackResource\",\n \"cloudformation:DescribeStackResources\",\n \"cloudformation:DescribeStackSet\",\n \"cloudformation:DescribeStackSetOperation\",\n \"cloudformation:DescribeStacks\",\n \"cloudformation:UpdateStack\",\n \"cloudformation:UpdateStackSet\",\n \"cloudfront:CreateCloudFrontOriginAccessIdentity\",\n \"cloudfront:CreateDistribution\",\n \"cloudfront:DeleteCloudFrontOriginAccessIdentity\",\n \"cloudfront:DeleteDistribution\",\n \"cloudfront:GetCloudFrontOriginAccessIdentity\",\n \"cloudfront:GetCloudFrontOriginAccessIdentityConfig\",\n \"cloudfront:GetDistribution\",\n \"cloudfront:GetDistributionConfig\",\n \"cloudfront:TagResource\",\n \"cloudfront:UntagResource\",\n \"cloudfront:UpdateCloudFrontOriginAccessIdentity\",\n \"cloudfront:UpdateDistribution\",\n \"cognito-identity:CreateIdentityPool\",\n \"cognito-identity:DeleteIdentityPool\",\n \"cognito-identity:DescribeIdentity\",\n \"cognito-identity:DescribeIdentityPool\",\n \"cognito-identity:SetIdentityPoolRoles\",\n \"cognito-identity:UpdateIdentityPool\",\n \"cognito-idp:CreateUserPool\",\n \"cognito-idp:CreateUserPoolClient\",\n \"cognito-idp:DeleteUserPool\",\n \"cognito-idp:DeleteUserPoolClient\",\n \"cognito-idp:DescribeUserPool\",\n \"cognito-idp:UpdateUserPool\",\n \"cognito-idp:UpdateUserPoolClient\",\n \"dynamodb:CreateTable\",\n \"dynamodb:DeleteItem\",\n \"dynamodb:DeleteTable\",\n \"dynamodb:DescribeTable\",\n \"dynamodb:PutItem\",\n \"dynamodb:UpdateItem\",\n \"dynamodb:UpdateTable\",\n \"iam:CreateRole\",\n \"iam:DeleteRole\",\n \"iam:DeleteRolePolicy\",\n \"iam:GetRole\",\n \"iam:GetUser\",\n \"iam:PassRole\",\n \"iam:PutRolePolicy\",\n \"iam:UpdateRole\",\n \"lambda:AddPermission\",\n \"lambda:CreateFunction\",\n \"lambda:DeleteFunction\",\n \"lambda:GetFunction\",\n \"lambda:GetFunctionConfiguration\",\n \"lambda:InvokeAsync\",\n \"lambda:InvokeFunction\",\n \"lambda:RemovePermission\",\n \"lambda:UpdateFunctionCode\",\n \"lambda:UpdateFunctionConfiguration\",\n \"s3:*\",\n \"amplify:*\"\n ],\n \"Resource\": \"*\"\n }\n ]\n}\n<\/pre>\n\n\n\n
Install Flutter and configure your first project<\/h2>\n\n\n\n