{
__http_transaction_h *transaction = (__http_transaction_h *)http_transaction;
__http_request_h *request = transaction->request;
+
struct stat file_info;
+ FILE *fp = fopen(request->upload_file, "rb");
+ if (!fp) {
+ ERR("Failed to open file!!");
+ return HTTP_ERROR_OPERATION_FAILED;
+ }
if (stat(request->upload_file, &file_info) != 0) {
ERR("stat() is failed.");
+ fclose(fp);
return HTTP_ERROR_OPERATION_FAILED;
}
- request->fp = fopen(request->upload_file, "rb");
+
+ request->fp = fp;
request->upload_size = (curl_off_t)file_info.st_size;
return HTTP_ERROR_NONE;
int _write_message_body(http_transaction_h transaction, const char *file_path)
{
- struct stat file_info;
FILE *fp;
size_t chunk_size = 50;
size_t result = 0;
char *buf = malloc(chunk_size + 1);
- if (stat(file_path, &file_info) != 0) {
- ERR("stat() is failed", -1);
- free(buf);
- return -1;
- }
-
- if (!S_ISREG(file_info.st_mode)) {
- ERR("path is not a regular file", -1);
- free(buf);
- return -1;
- }
-
fp = fopen(file_path, "rb");
if (!fp) {
free(buf);
printf("Input path: ");
ret = scanf("%1023s", path);
+ if (strlen(path) < 1)
+ return 0;
+
ret = http_session_open_transaction(session, HTTP_METHOD_POST, &transaction);
if (ret != 0) {
ERR("Fail to open transaction", ret);