Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Fix the multiplart form data

Acho Arnold6e84044b0de6
diff --git a/api/docs/docs.go b/api/docs/docs.go
index 908d34c3..21f3a971 100644
--- a/api/docs/docs.go
+++ b/api/docs/docs.go
@@ -11,7 +11,7 @@ const docTemplate = `{
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {
- "name": "HTTP SMS",
+ "name": "[email protected]",
"email": "[email protected]"
},
"license": {
@@ -151,9 +151,9 @@ const docTemplate = `{
"ApiKeyAuth": []
}
],
- "description": "Sends bulk SMS messages to multiple users from a CSV file.",
+ "description": "Sends bulk SMS messages to multiple users from a CSV or Excel file.",
"consumes": [
- "application/json"
+ "multipart/form-data"
],
"produces": [
"application/json"
@@ -162,6 +162,15 @@ const docTemplate = `{
"BulkSMS"
],
"summary": "Store bulk SMS file",
+ "parameters": [
+ {
+ "type": "file",
+ "description": "The Excel or CSV file formatted according to the templates",
+ "name": "document",
+ "in": "formData",
+ "required": true
+ }
+ ],
"responses": {
"202": {
"description": "Accepted",
@@ -3630,7 +3639,7 @@ const docTemplate = `{
"example": "153554b5-ae44-44a0-8f4f-7bbac5657ad4"
},
"send_at": {
- "description": "SendAt is an optional parameter used to schedule a message to be sent at a later time",
+ "description": "SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone.",
"type": "string",
"example": "2022-06-05T14:26:09.527976+03:00"
},
@@ -4362,7 +4371,7 @@ var SwaggerInfo = &swag.Spec{
BasePath: "/v1",
Schemes: []string{"https"},
Title: "httpSMS API Reference",
- Description: "API to send SMS messages using android [SmsManager](https://developer.android.com/reference/android/telephony/SmsManager) via HTTP",
+ Description: "Use your Android phone to send and receive SMS messages via a simple programmable API with end-to-end encryption.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
}
diff --git a/api/docs/swagger.json b/api/docs/swagger.json
index fb49b100..5cef4eb0 100644
--- a/api/docs/swagger.json
+++ b/api/docs/swagger.json
@@ -2,10 +2,10 @@
"schemes": ["https"],
"swagger": "2.0",
"info": {
- "description": "API to send SMS messages using android [SmsManager](https://developer.android.com/reference/android/telephony/SmsManager) via HTTP",
+ "description": "Use your Android phone to send and receive SMS messages via a simple programmable API with end-to-end encryption.",
"title": "httpSMS API Reference",
"contact": {
- "name": "HTTP SMS",
+ "name": "[email protected]",
"email": "[email protected]"
},
"license": {
@@ -133,11 +133,20 @@
"ApiKeyAuth": []
}
],
- "description": "Sends bulk SMS messages to multiple users from a CSV file.",
- "consumes": ["application/json"],
+ "description": "Sends bulk SMS messages to multiple users from a CSV or Excel file.",
+ "consumes": ["multipart/form-data"],
"produces": ["application/json"],
"tags": ["BulkSMS"],
"summary": "Store bulk SMS file",
+ "parameters": [
+ {
+ "type": "file",
+ "description": "The Excel or CSV file formatted according to the templates",
+ "name": "document",
+ "in": "formData",
+ "required": true
+ }
+ ],
"responses": {
"202": {
"description": "Accepted",
@@ -3323,7 +3332,7 @@
"example": "153554b5-ae44-44a0-8f4f-7bbac5657ad4"
},
"send_at": {
- "description": "SendAt is an optional parameter used to schedule a message to be sent at a later time",
+ "description": "SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone.",
"type": "string",
"example": "2022-06-05T14:26:09.527976+03:00"
},
diff --git a/api/docs/swagger.yaml b/api/docs/swagger.yaml
index a4124b82..efc316c4 100644
--- a/api/docs/swagger.yaml
+++ b/api/docs/swagger.yaml
@@ -658,7 +658,8 @@ definitions:
send_at:
description:
SendAt is an optional parameter used to schedule a message to
- be sent at a later time
+ be sent in the future. The time is considered to be in your profile's local
+ timezone.
example: "2022-06-05T14:26:09.527976+03:00"
type: string
to:
@@ -1185,10 +1186,10 @@ host: api.httpsms.com
info:
contact:
- name: HTTP SMS
description:
- API to send SMS messages using android [SmsManager](https://developer.android.com/reference/android/telephony/SmsManager)
- via HTTP
+ Use your Android phone to send and receive SMS messages via a simple
+ programmable API with end-to-end encryption.
license:
name: AGPL-3.0
url: https://raw.githubusercontent.com/NdoleStudio/http-sms-manager/main/LICENSE
@@ -1280,8 +1281,14 @@ paths:
/bulk-messages:
post:
consumes:
- - application/json
- description: Sends bulk SMS messages to multiple users from a CSV file.
+ - multipart/form-data
+ description: Sends bulk SMS messages to multiple users from a CSV or Excel file.
+ parameters:
+ - description: The Excel or CSV file formatted according to the templates
+ in: formData
+ name: document
+ required: true
+ type: file
produces:
- application/json
responses:
diff --git a/api/pkg/handlers/bulk_message_handler.go b/api/pkg/handlers/bulk_message_handler.go
index 5299fb0f..1c85be4f 100644
--- a/api/pkg/handlers/bulk_message_handler.go
+++ b/api/pkg/handlers/bulk_message_handler.go
@@ -48,13 +48,14 @@ func (h *BulkMessageHandler) RegisterRoutes(router fiber.Router, middlewares ...
router.Post("/v1/bulk-messages", h.computeRoute(middlewares, h.Store)...)
}
-// Store sends bulk SMS messages from a CSV file.
+// Store sends bulk SMS messages from a CSV or Excel file.
// @Summary Store bulk SMS file
-// @Description Sends bulk SMS messages to multiple users from a CSV file.
+// @Description Sends bulk SMS messages to multiple users from a CSV or Excel file.
// @Security ApiKeyAuth
// @Tags BulkSMS
-// @Accept json
+// @Accept multipart/form-data
// @Produce json
+// @Param document formData file true "The Excel or CSV file formatted according to the templates"
// @Success 202 {object} responses.NoContent
// @Failure 400 {object} responses.BadRequest
// @Failure 401 {object} responses.Unauthorized