Code Monkey home page Code Monkey logo

aws-s3-uploader-1's Introduction

AWS-S3-Uploader

A simple file uploader to amazon's S3 Bucket using PHP

Steps to Run

tep 1 - Set up an AWS account: If you don't have an Amazon Web Services (AWS) account, create one at https://aws.amazon.com/

Step 2 - Goto Services and search for S3 Step 3 - Open it, Tap "Create Bucket"

  • Enter Bucket Name
  • Select AWS Region (In my case..I live in india, so Asia Pacific (Mumbai) for me..)
  • COMPULSORY >> ACLs Enabled & Object Ownership > Object Writer
  • Untick all "Block Public Access settings for this bucket" & acknowledge it - Keep other setting as it is, and tap "Create Bucket"

Step 4 - Open the Bucket, goto "Permissions Tab", Scroll down and Lookup for "Bucket Policy"

Step 5 - Edit it and Paste this into Typing Area (Policy Area) and tap "Save Changes"


{
    "Version": "2012-10-17",
    "Id": "S3-Console-Auto-Gen-Policy-1691067582358",
    "Statement": [
        {
            "Sid": "S3PolicyStmt-DO-NOT-MODIFY-1691067582242",
            "Effect": "Allow",
            "Principal": {
                "Service": "logging.s3.amazonaws.com"
            },
            "Action": "s3:PutObject",
            "Resource": "arn:aws:s3:::damnbruh/*"
        },
        {
            "Sid": "S3PolicyStmt-Allow-Upload",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:PutObject",
            "Resource": "arn:aws:s3:::damnbruh/*"
        }
    ]
}

Step 6 - Go Down, and lookup for "Access control list (ACL)" & Grant all permissions or Read and Write (whichever can be ticked)

Step 7 - Now Goto Dashboard of aws, on top, search for "IAM" service.

Step 8 - In the IAM dashboard, click on "Users" in the left sidebar.

Step 9 - Click on the "Add user" button to create a new IAM user.

Step 10 - Provide a username for the new IAM user. You can choose any name that helps you identify the user's purpose, such as "s3-uploader." & Press Next & Create User..

Step 11 - You will be greeted with "Access Key" & "Secret Key" Copy it somewhere safe because those keys will be lost once you close the window.

Step 12 - Now you have your S3 Bucket created and you have your access key/secret keys...now it time to run the PHP File Locally/Hosted

Step 13 - Install XAMPP (https://www.apachefriends.org/download.html)

Step 14 - Install Composer (https://getcomposer.org/Composer-Setup.exe)

Step 15 - While installing composer, you may need to select the PHP PATH, it will automatically pop, but if it doesnt, click browse and navigate to your xampp folder, xampp/php/php.exe and select it.

Step 16 - Open XAMPP, Start Apache, and to the side, there will be "Explorer", Tap it..

Step 17 - Now open Terminal/CMD/Powershell in the folder that just opened (htdocs)

Step 18 - In terminal paste this code to install AWS SDK

composer require aws/aws-sdk-php

Step 19 - A new folder "vendor" will be created with AWS folder inside it..

Step 20 - Place the "S3-Bucket-Uploader.php" which you downloaded from GitHub into the "htdocs" folder.

Step 21 - Make sure to replace YOUR_ACCESS_KEY, YOUR_SECRET_KEY, and YOUR_BUCKET_NAME with your actual AWS credentials and bucket name (You have to change total 4 keys and 2 bucket names)

Step 22 - Goto your browser, and search 'localhost' in address bar.

Step 23 - The Project should be up and running.

aws-s3-uploader-1's People

Contributors

pranavsatav avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.