Upload File
Request address
POST
https://sandbox.j-pay.net/pay/merchant/create
Test account
Merchant ID:10010
ApiKey: 7e4nicn14nhyup146dfbi8hpnpus9juz
Request headers
| Header Name | Header Value |
|---|---|
| Agent-Merchant-Id | 10010 |
Request parameters
Request parameters
| Parameter Name | Type | Required | Sign(Y OR N) | Parameter Description |
|---|---|---|---|---|
| memberid | String | Y | Y | Merchant ID |
| file | File | Y | N | The file to be uploaded. |
| sign | String | Y | N | Please see the verification signature field format |
Response Parameters
| Parameter Name | Type | Parameter Description |
|---|---|---|
| code | String | Status of the request 1:Successful 0:Fail |
| info | String | Message of the request |
| data | Array | The uploaded file information. |
| data.id | Integer | The unique identifier of the uploaded file. |
Demo
- Javascript
- Php
- Python
import { md5 } from "js-md5";
import axios from "axios";
import FormData from 'form-data';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const CONFIG = {
KEY: "7e4nicn14nhyup146dfbi8hpnpus9juz",
AGENT_ID: "10010",
MEMBER_ID: "10304",
UPLOAD_URL: "https://sandbox.j-pay.net/pay/upload/file",
IMAGE_PATH: path.resolve(__dirname, './cashapp.png')
};
function uploadFile() {
if (!fs.existsSync(CONFIG.IMAGE_PATH)) {
throw new Error(`File not found: ${CONFIG.IMAGE_PATH}`);
}
const query = { memberid: CONFIG.MEMBER_ID };
const signData = Object.keys(query)
.sort()
.map(key => `${key}=${query[key]}`);
signData.push(`key=${CONFIG.KEY}`);
const sign = md5(signData.join("&")).toUpperCase();
const formData = new FormData();
formData.append('file', fs.createReadStream(CONFIG.IMAGE_PATH), {
filename: 'cashapp.png',
contentType: 'image/png'
});
formData.append('memberid', CONFIG.MEMBER_ID);
formData.append('sign', sign);
axios.request({
url: CONFIG.UPLOAD_URL,
method: "post",
headers: {
"Agent-Merchant-Id": CONFIG.AGENT_ID,
...formData.getHeaders()
},
data: formData,
}).then((response) => {
console.log("Upload Success:", response.data);
return response.data;
}).catch((error) => {
console.error("Upload Failed:", error);
throw error;
});
}
uploadFile();
Continuously updating...
Continuously updating...