使用UTL_HTTP進行文件上傳和下載需要以下步驟:
DECLARE
req UTL_HTTP.req;
resp UTL_HTTP.resp;
BEGIN
NULL;
END;
req := UTL_HTTP.begin_request('http://example.com/upload_file', 'POST', 'HTTP/1.1');
UTL_HTTP.set_header(req, 'Content-Type', 'multipart/form-data');
UTL_HTTP.set_body_charset(req, 'UTF-8');
UTL_HTTP.set_multipart_boundary(req, 'boundary');
UTL_HTTP.write_text(req, '--boundary');
UTL_HTTP.write_text(req, 'Content-Disposition: form-data; name="file"; filename="file.txt"');
UTL_HTTP.write_text(req, 'Content-Type: text/plain');
UTL_HTTP.write_text(req, 'Content-Transfer-Encoding: binary');
UTL_HTTP.write_text(req, '');
UTL_HTTP.write_text(req, 'file content');
UTL_HTTP.write_text(req, '--boundary--');
resp := UTL_HTTP.get_response(req);
IF resp.status_code = 200 THEN
UTL_HTTP.read_text(resp, 'response.txt');
END IF;
通過以上步驟,您可以使用UTL_HTTP進行文件上傳和下載操作。請注意,您需要有相應的權限來執行這些操作,并且需要確保網絡連接正常。