Google Cloud App Engine에서 실행되는 노드 js 서버 서비스가 있습니다. 프로세스에서 업데이트해야하는 프로젝트의 자산 폴더에 JSON 파일이 있습니다. 파일 내부의 파일과 구성을 읽을 수있었습니다. 그러나 파일을 추가하면 GAE에서 읽기 전용 서비스 오류가 발생합니다.
클라우드 스토리지 옵션을 사용하지 않고 파일에 정보를 쓸 수있는 방법이 있습니까?
아주 작은 파일이고 클라우드 저장소를 사용하는 것은 Allen 렌치 나사에 매우 큰 드릴 머신을 사용하는 것입니다.
감사
문제에 대한 해킹 솔루션을 찾는 데 시간을 낭비하지 않도록 안내해 주셔서 감사합니다.
어떤 식 으로든 / tmp 디렉토리를 사용하고 앱 엔진에서 호스팅하는 node.js 애플리케이션을 사용하여 파일을 다운로드 / 업로드하는 방법에 대한 명확한 코드가 없었습니다. 누군가 필요한 경우 다음 코드가 있습니다.
const {
Storage
} = require('@google-cloud/storage');
const path = require('path');
class gStorage {
constructor() {
this.storage = new Storage({
keyFile: 'Please add path to your key file'
});
this.bucket = this.storage.bucket(yourbucketname);
this.filePath = path.join('..', '/tmp/YourFileDetails');
// I am using the same file path and same file to download and upload
}
async uploadFile() {
try {
await this.bucket.upload(this.filePath, {
contentType: "application/json"
});
} catch (error) {
throw new Error(`Error when saving the config. Message : ${error.message}`);
}
}
async downloadFile() {
try {
await this.bucket.file(filename).download({
destination: this.filePath
});
} catch (error) {
throw new Error(`Error when saving the config. Message : ${error.message}`);
}
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다