We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<!--<script src="/static/js/ckeditor5.js"></script>--> <script src="https://cdn.ckeditor.com/ckeditor5/35.0.1/classic/ckeditor.js"></script>
ClassicEditor.create( document.querySelector( '#content' ), { language: "ko", ckfinder : { uploadUrl : "/image/upload", } } ) .catch(error => { console.error(error); });
package com.grepp.ck.controller;
//import com.grepp.ck.service.GCSFileUploadService; //import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.http.ResponseEntity; //import org.springframework.stereotype.Controller; //import org.springframework.beans.factory.annotation.Value; //import org.springframework.web.bind.annotation.PostMapping; //import org.springframework.web.bind.annotation.RequestParam; //import org.springframework.web.bind.annotation.ResponseBody; //import org.springframework.web.bind.annotation.RestController; //import org.springframework.web.multipart.MultipartFile; //import org.springframework.web.multipart.MultipartRequest; // //import java.io.IOException; //import java.util.Map; // //@RestController //public class ImageUploadController { // // @Autowired // private GCSFileUploadService gcsFileUploadService; // // @value("${gcp.bucket.name}") // private String bucketName; // // @PostMapping("/image/upload") // public ResponseEntity<?> uploadImage(@RequestParam("upload") MultipartFile file) throws IOException { // try { // String imageUrl = gcsFileUploadService.uploadFile(file); // // return ResponseEntity.ok("{"url":"" + imageUrl + ""}"); // } catch (IOException e) { // return ResponseEntity.status(500).body("{"error":"" + e.getMessage() + ""}"); // } // }
import com.google.cloud.storage.Blob; import com.google.cloud.storage.Bucket; import com.google.cloud.storage.Storage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile;
@RestController public class ImageUploadController {
@Autowired private Storage storage; @Value("${gcp.bucket.name}") private String bucketName; @PostMapping("/image/upload") public ResponseEntity<?> uploadImage(@RequestParam("upload") MultipartFile file) { try { // GCS 버킷 객체를 가져옵니다. Bucket bucket = storage.get(bucketName); String fileName = file.getOriginalFilename(); // GCS에 파일을 직접 업로드합니다. Blob blob = bucket.create(fileName, file.getBytes(), file.getContentType()); // 업로드된 파일의 URL을 반환합니다. String imageUrl = blob.getMediaLink(); // CKEditor의 응답 형식에 맞게 JSON 응답을 반환합니다. return ResponseEntity.ok("{\"url\":\"" + imageUrl + "\"}"); } catch (Exception e) { // 오류가 발생하면 500 상태 코드와 함께 에러 메시지를 반환합니다. return ResponseEntity.status(500).body("{\"error\":\"" + e.getMessage() + "\"}"); } }
}
help me plz
The text was updated successfully, but these errors were encountered:
No branches or pull requests
<textarea name="content" id="content">{{#data}}{{data.content}}{{/data}}</textarea>
<script>
package com.grepp.ck.controller;
//import com.grepp.ck.service.GCSFileUploadService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.ResponseEntity;
//import org.springframework.stereotype.Controller;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//import org.springframework.web.multipart.MultipartRequest;
//
//import java.io.IOException;
//import java.util.Map;
//
//@RestController
//public class ImageUploadController {
//
// @Autowired
// private GCSFileUploadService gcsFileUploadService;
//
// @value("${gcp.bucket.name}")
// private String bucketName;
//
// @PostMapping("/image/upload")
// public ResponseEntity<?> uploadImage(@RequestParam("upload") MultipartFile file) throws IOException {
// try {
// String imageUrl = gcsFileUploadService.uploadFile(file);
//
// return ResponseEntity.ok("{"url":"" + imageUrl + ""}");
// } catch (IOException e) {
// return ResponseEntity.status(500).body("{"error":"" + e.getMessage() + ""}");
// }
// }
import com.google.cloud.storage.Blob;
import com.google.cloud.storage.Bucket;
import com.google.cloud.storage.Storage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
public class ImageUploadController {
}
help me plz
The text was updated successfully, but these errors were encountered: