Hi I am using the following code in java to upload the file to synapse,
S3FileHandle result;
result = synapseClient.multipartUpload(file,storageLocationId,generatePreview,forceRestart);
FileEntity fileEntity = new FileEntity();
fileEntity.setDataFileHandleId(result.getId());
fileEntity = synapseClient.createEntity(fileEntity);
Here the storageLocationId is long, Can anyone help me what value should be given for storageLocationId ?
Created by alekhya bellam alekhya I can able to do that by using fileEntity.setName(). Thank You Thank You so much, Now i can able to upload the file. But i found that file name is showing as "synXXXXXX" in synapse instead of my file name. Is there any way that i can change the file name from code ? Before calling `createEntity`, you need to set the FileEntity's parent, to control where it goes:
```
String parentId = "synXXXXXX"; // ID of the folder or project in which you wish the file to appear
fileEntity.setParentId(parentId);
fileEntity = synapseClient.createEntity(fileEntity);
```
Hi Kenneth,
Thanks for helping me. I want to store the file in synapse storage. When i run the code using null value for storageLocationId, the code runs fine but i can not able to see the file in my synapse account.
Below is my full code
public static String PROD_REPO_URL = "https://repo-prod.prod.sagebase.org/repo/v1";
public static String PROD_AUTH_URL = "https://repo-prod.prod.sagebase.org/auth/v1";
public static String PROD_FILE_URL = "https://repo-prod.prod.sagebase.org/file/v1";
SynapseClient synapseClient = new SynapseClientImpl();
synapseClient.setUsername("my user name");
synapseClient.setApiKey("my api key");
synapseClient.setRepositoryEndpoint(PROD_REPO_URL);
synapseClient.setAuthEndpoint(PROD_AUTH_URL);
synapseClient.setFileEndpoint(PROD_FILE_URL);
String FILE_PATH = "/tmp/";
File file = new File(FILE_PATH+"fileName.csv");
Long storageLocationId = null;
Boolean generatePreview = true;
Boolean forceRestart = null;
S3FileHandle result;
result = synapseClient.multipartUpload(file,storageLocationId,generatePreview,forceRestart);
FileEntity fileEntity = new FileEntity();
fileEntity.setDataFileHandleId(result.getId());
fileEntity = synapseClient.createEntity(fileEntity);
Can any one help me why the file is not storing in my account
@DwayneJengSage suggested that `NULL` is probably the value you are looking for, if you want to upload to Synapse Storage. If you have your own S3 bucket you are using (as described here: http://docs.synapse.org/articles/custom_storage_location.html) then you would need to use the REST calls noted above. I believe it can be determined from the following REST call: http://docs.synapse.org/rest/GET/storageLocation.html
You'll get back one of these (http://docs.synapse.org/rest/org/sagebionetworks/repo/model/project/StorageLocationSetting.html) and the type for `storageLocationId` is an `integer`.
I can't comment on how to do that in Java - @john-hill, @brucehoff have any suggestions?
Drop files to upload
Problem Uploading File to Synapse page is loading…