Get the latest version of Windows and Office with kmspico setup freeQ:
Clean REST API vs. multipart upload in file
I've been working with a REST API for the past week or so. I am creating multiple files which are already uploaded to a temporary location on the server. I use the multipart api to upload these files.
This is an example call:
public function setShareData(Request $request)
{
$data = $request->all();
//file stuff
$this->share->createShare(
$data,
$user,
$data['filename'],
'public'
);
}
This works, however it appears to be uploading the files as multipart form data, which means that we can't have a REST api call to that method.
We are in the middle of migrating from a proprietary file system to an open source filesystem (Ceph) and we need to be able to upload these files using the REST api.
The files we are uploading are just 20MB, they are already uploaded to the server. What is the best approach for this scenario? Is there a best practice for this type of file upload?
Update:
After doing some research, we were able to use the REST API to do this, though we are still trying to find a way to keep the files in the Ceph filesystem.
Here is an example call using the REST api:
public function setShareData(Request $request)
{
$file = new File();
$file->setFilename($request->get('filename'));
$file->setSize($request->get('size'));
$file->setOwnerId($user->id);
$file->setLocation($request->get('location'));
$response = $this->share->createShare(
$file,
$user,
$file->getFilename(),
'public'
);
}
The key here is that we ac619d1d87
Related links:
Comments