You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,7 @@ Table of Contents:
66
66
|**[NGINX CORS Private](containers/nginx-cors-private-python/README.md)** <br/> An NGINX proxy to allow CORS requests to a private container. | Python Flask |[Terraform]|
67
67
|**[NGINX hello world](containers/nginx-hello-world/README.md)** <br/> A minimal example running the base NGINX image in a serverless container. | N/A |[Serverless Framework]|
68
68
|**[Python hello world](containers/python-hello-world/README.md)** <br/> A minimal example running a Flask HTTP server in a serverless container. | N/A |[Serverless Framework]|
69
+
|**[Python S3 upload](containers/python-s3-upload/README.md)** <br/> A Python + Flask HTTP server that receives file uploads and writes them to S3. | N/A |[Terraform]|
69
70
|**[Terraform NGINX hello world](containers/terraform-nginx-hello-world/README.md)** <br/> A minimal example running the base NGINX image in a serverless container deployed with Terraform. | N/A |[Terraform]|
70
71
|**[Triggers with Terraform](containers/terraform-triggers/README.md)** <br/> Configuring two SQS triggers, used to trigger two containers, one public, one private. | N/A |[Terraform]|
- You have an account and are logged into the [Scaleway console](https://console.scaleway.com)
11
+
- You have created an API key in the [console](https://console.scaleway.com/iam/api-keys), with at least the `ObjectStorageFullAccess`, `ContainerRegistryFullAccess`, and `FunctionsFullAccess` permissions, plus access to the relevant project for Object Storage
12
+
- You have [Terraform](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs) installed on your machine
13
+
- You have logged in to the Scaleway Container Registry (`scw registry login`)
14
+
15
+
## Deploy on Scaleway
16
+
17
+
First you need to set the following environment variables:
Copy file name to clipboardExpand all lines: functions/python-upload-file-s3-multipart/README.md
+40-19
Original file line number
Diff line number
Diff line change
@@ -3,42 +3,63 @@
3
3
This function does the following steps:
4
4
5
5
* Read a file from an HTTP request form
6
-
*Send the file to long-term storage with Glacier for S3
6
+
*Store the file in S3
7
7
8
8
## Requirements
9
9
10
-
This example uses the [Python API Framework](https://github.com/scaleway/serverless-api-project) to deploy the function.
10
+
This example uses the [Python API Framework](https://github.com/scaleway/serverless-api-framework-python) to build and deploy the function.
11
11
12
-
If needed, create a bucket and provide the following variables in your environment:
12
+
First you need to:
13
13
14
-
```env
15
-
export SCW_ACCESS_KEY =
16
-
export SCW_SECRET_KEY =
17
-
export BUCKET_NAME =
18
-
```
14
+
- Create an API key in the [console](https://console.scaleway.com/iam/api-keys), with at least the `ObjectStorageFullAccess` and `FunctionsFullAccess` permissions, and access to the relevant project for Object Storage access
15
+
- Get the access key and secret key for this API key
16
+
- Get your project ID
17
+
- Create an S3 bucket
19
18
20
-
## Running
19
+
You then need to set the following environment variables:
21
20
22
-
### Running locally
21
+
```bash
22
+
export SCW_ACCESS_KEY=<your access key>
23
+
export SCW_SECRET_KEY=<your secret key>
24
+
export SCW_DEFAULT_PROJECT_ID=<your project id>
25
+
export BUCKET_NAME=<bucket name>
26
+
```
23
27
24
-
This examples uses [Serverless Functions Python Framework](https://github.com/scaleway/serverless-functions-python) and can be executed locally:
28
+
## Deploy on Scaleway
29
+
30
+
Deployment can be done with `scw_serverless`:
25
31
26
32
```bash
27
-
pip install -r requirements-dev.txtbash
28
-
python app.py
33
+
pip install --user -r requirements.txt
34
+
35
+
scw-serverless deploy app.py
29
36
```
30
37
31
-
The upload endpoint allows you to upload files to Glacier via the `file` form-data key:
38
+
This will then print out your function's URL. You can use this to test your function with:
32
39
33
40
```bash
34
-
echo -e 'Hello world!\n My contents will be stored in a bunker!'> myfile.dat
35
-
curl -F file=@myfile.dat localhost:8080
41
+
# Upload the requirements file
42
+
curl -F file=@requirements.txt <your functionURL>
36
43
```
37
44
38
-
### Deploying with the API Framework
45
+
You should then see the `requirements.txt` file uploaded to your bucket.
39
46
40
-
Deployment can be done with `scw_serverless`:
47
+
_Warning_ when deploying the function, do not create a virtual environment directory in this project root, as this will be included in the deployment zip and make it too large.
48
+
49
+
## Running it locally
50
+
51
+
You can test your function locally thanks to the [Serverless Functions Python Framework](https://github.com/scaleway/serverless-functions-python). To do this, you can run:
52
+
53
+
```bash
54
+
pip install --user -r requirements-dev.txt
55
+
56
+
python app.py
57
+
```
58
+
59
+
This starts the function locally, allowing you to upload files to S3 via the `file` form-data key:
0 commit comments