DreamFactory : 파일 서버에 이미지를 업로드하고 데이터베이스에 이미지 경로를 저장하는 방법은 무엇입니까?

트리스탄 G

DreamFactory를 API로 사용할 생각입니다. 나는 serversice-logic에 신선합니다. 파일 시스템에 이미지를 저장하고 저장된 파일의 경로를 데이터베이스에 저장하고 싶습니다. 나는 이미지를 데이터베이스 내부에 blob으로 저장하지 않을 것입니다. 아무도 나를 올바른 방향으로 안내해 주시겠습니까?

먼저 다음을 사용하여 이미지를 파일 시스템에 게시합니다.

post /files/{file_path} 

그리고 나서:

post /mysql/_table/{table_name} createRecords() - Create one or more records

그러나 데이터베이스에 경로를 전달하는 방법은 무엇입니까?

리 힉스

한 가지 방법은 / files / {file_path}에 대한 POST에서 서버 측 스크립팅 (이 경우 V8J)을 사용하는 것입니다. 관리 응용 프로그램, 스크립트 탭으로 이동하고 이벤트를 통해 다음 경로로 이동하십시오.

Process Event Scripts > files > files.{file_path} > [POST] files.{file_path} > files.{file_path}.post.post_process

다음 스크립트를 시도하십시오 ...

// event.resource is the {file_path} part, 
// including any folders from root, i.e. my/path/file.txt
var_dump(event.resource); 

// Create a record that you want to post to a table, 
// using the "todo" table for example, setting "name" to the file path
// "mysql" is my db service name
var record = {"resource": [ {"name": event.resource, "complete": false } ] }; 
var result = platform.api.post('mysql/_table/todo', record);

var_dump(result); 
// result contains a resource array with the id of the record created
// like {"resource": [ {"id": 5} ] }

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관