How to make file upload api call in pantaris files storage?

Hi, I want to upload a file to pantaris files storage using File api. I have tried this explorer (PANTARIS Upload API). But I am missing something, Here I am giving what I have tried in postman.

url endpoint → https://upload.pantaris.io/files
method → POST
Headers →
Authorization : Token <calponia_token>
Tus-Resumable : 1.0.0
Upload-Metadata : directoryId=<directory_id>;fileName=<file_name>;authorization=“Token <calponia_token>”;
Request Body : formdata
fileName : <attached_file>

I am getting 500 internal server error saying → {“error”:{“status”:400,“code”:“INPUT_IS_REQUIRED”,“title”:“Input is required”,“detail”:“The input field ‘fileName’ is required”}}

I am missing something in Upload-Metadata header. But I couldn’t find. I have disabled bosch wifi network (because getting 407 error) and using my personal network and connected vpn.

P.S. I am able to access download api. Its working fine.

Hi @fmt1cob ,

make sure to base64-encode your values in the metadata-header.

Please find more information here Documentation | PANTARIS . Suggest to use a libary for handling tus rather than make the requests yourself to prevent such issues. Find an offical list here: Implementations | tus.io

2 Likes

I have tried this
Upload-Metadata : directoryId=<base_64_encoded_directory_id>;fileName=<base_64_encoded_file_name>;authorization=“Token <base_64_encoded_calponia_token>”;

Still getting the same error
{“error”:{“status”:400,“code”:“INPUT_IS_REQUIRED”,“title”:“Input is required”,“detail”:“The input field ‘fileName’ is required”}}

I will try using tus

Is the value of Upload-Metadata is correct? or I need to modify something here? Can anyone share sample upload metadata value which is working properly?

I have tried to call upload file api from my java code. I have given the implementation below. But getting this error → io.tus.java.client.ProtocolException: unexpected status code (412) while creating upload
on this line tusClient.resumeOrCreateUpload(tusUpload); 412 error is based on Upload-Length / Upload-Defer-Length. But I have those header. Anything I am missing here?

try {
			tusClient.setUploadCreationURL(new URL("https://upload.pantaris.io/files/"));
		} catch (MalformedURLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		// Create a new TusUpload instance
		File file = new File("C:\\Users\\<user_id>\\Downloads\\signal_catalog_schema.json");

		// Set the authorization header
		tusClient.setHeaders(Collections.singletonMap("Authorization", "Token <calponia_token>"));
		tusClient.setHeaders(Collections.singletonMap("Tus-Resumable", "1.0.0"));
		tusClient.setHeaders(Collections.singletonMap("Upload-Length", String.valueOf(file.length())));
		//tusClient.setHeaders(Collections.singletonMap("Upload-Defer-Length", "2342"));
		
		
		TusUpload tusUpload = null;
		try {
			tusUpload = new TusUpload(file);
		

		// Set the file name and access token in the Upload-Metadata header
		Map<String, String> metadata = new HashMap<>();
		metadata.put("directoryId", "3f77a1f8-2bc0-11ee-a5a1-a71702e59a0a");
		metadata.put("fileName", file.getName());
		metadata.put("accessToken", "Token <calponia_token>");
		tusUpload.setMetadata(metadata);
		// Set the file size in the Upload-Length header
		tusUpload.setSize(file.length());
		
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		 // Create a new TusUploader instance
        TusUploader tusUploader;
		try {
			tusUploader = tusClient.resumeOrCreateUpload(tusUpload);
			tusUploader.uploadChunk();
		} catch (ProtocolException | IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

Hi @fmt1cob
as far as i can see from the tus protocol definition the error 412 is due to a not matching tus version, see Resumable upload protocol 1.0.x | tus.io . But nonetheless your provided version is 1.0.0 and this is what we support.
Can you please provide the complete response headers, including the Tus-Version header?

Kind Regards,
Hans