> For the complete documentation index, see [llms.txt](https://motivlabs.gitbook.io/diesel/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://motivlabs.gitbook.io/diesel/api-example-requests/upload-a-file.md).

# Upload a File

This method can handle two different calls, one where a file path is passed, and a second where it does not receive a , and it means we are going to use the MD5 of the file as the file name.

## Using file name:

URL: > files/{bucketname}/{path:.\*}

HTTP Method: PUT

Response: if the file was uploaded, returns:

````javascript
{
  "bucket": "<bucket name>",
  "objectName": "<file name>",
  "parentPath": "<file path>",
  "checksum": "<MD5 checksum>",
  "size": <file size>
}
``

Example

```text
curl -X PUT -T ~/Downloads/image1.jpg PUT http:localhost:8080/files/bucket1/folder1/folder2/image.jpg
``

Response:

```json
{
  "bucket": "bucket1",
  "objectName": "image.jpg",
  "parentPath": "/folder1/folder2/",
  "checksum": "86af350cbceb14672fdcaee11bc2571a",
  "size": 66779
}
````

## Without file name:

URL: > files/{bucketname}/{path:.\*}

HTTP Method: PUT

Response: if the file was uploaded, returns:

```javascript
{
  "bucket": "<bucket name>",
  "objectName": "<MD5 checksum>",
  "parentPath": "/",
  "checksum": "<MD5 checksum>",
  "size": <file size>
}
```

Example:

```
curl -X PUT -T ~/Downloads/image1.jpg PUT http:localhost:8080/files/bucket1
```

Response:

```javascript
{
  "bucket": "bucket1",
  "objectName": "86af350cbceb14672fdcaee11bc2571a",
  "parentPath": "/",
  "checksum": "86af350cbceb14672fdcaee11bc2571a",
  "size": 66779
}
```

## Get a File

```
http://localhost:8080/files/<bucketName>/folder1/folder2/test.deb
```

## Delete a file

```
DELETE 
    http://localhost:8080/files/<bucketName>/{path:.*}
HEADER:
    Bucket: <bucketName>
```

Example:

```
curl --location --request DELETE 'http://localhost:8080/files/my-bucket/folder1/folder2/test.deb' \
--header 'Bucket: <bucketName>'
```

## List Files

This method list all the file names under a bucket and parent path (folder)

Example 1:

```
curl -X GET http:localhost:8080/files/my-bucket/my-folder
```

Example 2:

```
curl -X GET http:localhost:8080/files/my-bucket
```

Response:

```javascript
{
    "files": [
        "diesel.jpg", "LOTR.pdf"
    ]
}
```

## App Ready

Check if the app is ready:

```
curl -v -X GET "http://localhost:8080/appReady"
```
