opendatatrentino / jackan

Java client to access CKAN repositories
http://opendatatrentino.github.io/jackan
Other
19 stars 13 forks source link

Need help on sending a csv file as a resource #43

Closed gambit4348 closed 5 years ago

gambit4348 commented 5 years ago

Hello I'm trying to create a new dataset with a csv file as a resource. The send process runs with no errors, but in CKAN I can't access the csv content. My code is as follows:

    dataset.setResources(new ArrayList<CkanResource>());
    String fileName = "test.csv";
    CkanResource resource = new CkanResource(CKAN.ckanDatasetUrl + "/" + fielName, fileName);
    resource.setId(UUID.randomUUID().toString());
    resource.setName(fileName);
    resource.setFormat("csv");
    resource.setMimetype("text/csv");
    StringBody body = new StringBody(csvContent, ContentType.MULTIPART_FORM_DATA);
    resource.putOthers("upload", body);

Any help will be very helpful.

Sincerely,

Alex

nabdali commented 5 years ago

Hello,

I think it doesn't work because you put the file in others properties : resource.putOthers("upload", body);.

Try this :

CkanResourceBase ckanResourceBase = new CkanResourceBase();
ckanResourceBase.setPackageId(packageId);
ckanResourceBase.setUrl("upload");
ckanResourceBase.setId(id);
ckanResourceBase.setUpload(dataFile, true);

 

gambit4348 commented 5 years ago

Thanks for your answer.

I noticed that the current version in GitHub is 0.4.3, and it provides the setUpload() method. However, I'm using the version 0.4.2, because that one is the most up-to-date one existing in MvnRepository.

Is it possible to you to upload the version 0.4.3 to MvnRepository? I believe it will fix the issue to me.

Thanks in advance!

nabdali commented 5 years ago

No I can't, but on a project I had used the version 0.4.3 'eu.trentorise.opendata:jackan:0.4.3-SNAPSHOT' https://sourcegraph.com/github.com/ozwillo/ozwillo-dc-exporter@DEMO_JUS_2016/-/blob/build.gradle#L54

gambit4348 commented 5 years ago

That's too bad, I work with Maven, not Gradle. Also, I tryed to download and compile the version 0.4.3 locally, but it depends on a parent POM file:

<parent>
    <groupId>eu.trentorise.opendata</groupId>
    <artifactId>tod-super-pom</artifactId>
    <version>1.3.0</version>
</parent>

Problem is I don't have such a parent POM file, so I can't compile it myself. Would you please send me that parent POM so I can compile the project locally?

Thanks in advance!

gambit4348 commented 5 years ago

It seems I will not get any help, after all... Too bad, I'm forced to drop Jackan. Thanks anyway..