# Manage Multimedia Files

If you want to upload files to your Azure Blob Storage Subscriptions enabled in the application settings directly from hooks, this is how you can do it

```javascript
const multimediaService = require("./utils/multimediaService");

//upload from a buffer
await multimediaService.uploadFileBufferToAzureAsync(file);


//upload from a stream
await multimediaService.uploadFileStreamToAzureAsync(stream, file);

//remove a file from azure storage
await multimediaService.deleteFileFromAzureAsync("filename");

```

The `file` param should have the following attributes

```javascript

{
    mimetype, // string | required
    buffer // required if you are using uploadFileBufferToAzureAsync method
    filename
    originalname // required if you are not passing the filename
}

```

The returned object after calling any of those methods will have the next data

```javascript
{
    mimetype, 
    buffer 
    filename
    originalname,
    url, // this will be where you can find your file
    storage //azure by default if enabled
}
```

Additional Parameter for `uploadFileStreamToAzureAsync and` uploadFileBufferToAzureAsync

**omitPrefix** (boolean, optional): When set to `true`, the uploaded file's name will be set to the original name or the provided filename without a timestamp prefix. If set to `false`, the filename will include a timestamp prefix.

```javascript
const multimediaService = require("./utils/multimediaService");
//upload from a buffer 
await multimediaService.uploadFileBufferToAzureAsync(file, true); // omitPrefix 
//upload from a stream 
await multimediaService.uploadFileStreamToAzureAsync(stream, file, true); // omitPrefix 
```

```json
{
    "mimetype": "text/plain",
    "filename": "_file",
    "url": "https://urlazure/app/app/_file",
    "storage": "azure"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://codenull.gitbook.io/dev/configurations/hooks/manage-multimedia-files.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
