Skip to content

Unable to create documents and attaching files simultaneously #289

@swedhaselva

Description

@swedhaselva

this is my service implementation:

public String createAttachment(String docId) throws FileNotFoundException{
	try {
		CouchDbInstance dbInstance = getconnection();

		// creating database

		CouchDbConnector connector = new StdCouchDbConnector("demouser", dbInstance);
		CouchDbImpl impl = new CouchDbImpl(connector);
		connector.createDatabaseIfNotExists();

		String database = connector.getDatabaseName();
		System.out.println(database);
		
		InputStream inputstream = new FileInputStream("C:\\Users\\SwedhaS\\Desktop\\couchdb reference.txt");
		String contentType = "application/text";

		AttachmentInputStream a = new AttachmentInputStream("123456",
		                                                     inputstream,
		                                                     contentType);

		connector.createAttachment(docId, a);
	


	} catch (MalformedURLException e) {

		e.printStackTrace();
	}

	return null;
}
this is my controller:
@PostMapping("/save/{id}")
	public String createDocumentAndfiles(@RequestBody User user,@PathVariable String id) throws FileNotFoundException {
	String users=userRepo.createAttachment(id);
	return users;
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions