fardeen7337's avatar

pCloud

I am using pCloud to upload large files I have a form to post a file and I want save it directly to the pCloud don't save in public_path and then get from their and save it pCloud is their any way to post it direct pCloud using laravel

0 likes
12 replies
Snapey's avatar

you are assuming we have an idea what pcloud is ?

fardeen7337's avatar

No , I want to ask that how to solve that problem

fardeen7337's avatar

if ($request->hasfile('video')) {

            $pCloudFile = Pcloud::getFacadeRoot();

            $videoName = 'video' . time() . '.' . $uploadVideo->getClientOriginalExtension();

            $uploadVideo->move(public_path('storage/videos/'), $videoName);

            $videoPath = public_path('storage/videos/'.$videoName);

             $uploadedPcloudFile = $pCloudFile->upload($videoPath);

}

//pcloud upload function public function upload($path, $folderId = 0) { if (!file_exists($path) || !is_file($path) || !is_readable($path)) { throw new Exception("Invalid file"); }

	// $path = str_replace(array("\", "_"), "/", $path);
	$path = str_replace(array("\"), "/", $path);
	$parts = explode("/", $path);

	$upload = $this->createUpload();

	$params = array(
		"uploadid" => $upload->uploadid,
		"uploadoffset" => 0
	);

	$file = fopen($path, "r");
	while (!feof($file)) {
		$content = fread($file, $this->partSize);
		$this->write($params, $content);
		$params["uploadoffset"] += $this->partSize;
	}
	fclose($file);

	return $this->save($upload->uploadid, end($parts), $folderId);
}

how to upload the request->video direct on pcloud without saving it in public directory

fardeen7337's avatar

@snapey I checked the document to but their is nothing which tells us to upload the file on pCloud without saving it in public directory have you any idea?

fardeen7337's avatar

@snapey If I save the file in public directory then upload it on pCloud it works fine but I want to upload the file directly on pCloud

Snapey's avatar

@fardeen7337 If it had a half descent API, you could obtain a one-time upload token and send the file direct from the browser to the cloud storage without it ever touching your server.

Why can you not just give the API the temporary file upload path?

fardeen7337's avatar

@snapey it's not getting from there it only get file from directory then upload it on pCloud but when I deploy my application to liver server I upload 1 or 4 GB files the post_max_size error I know server can't handle that request that's why I want to upload it direct on pCLoud I am finding the solution to upload direct but it there is no solution so I have to upload the files in chunk on server then get it from there and upload it on pCloud but it will be lengthy work that's why I am finding to upload it direct

fardeen7337's avatar

@snapey right snappy that what I am searching but didn't find anything so I prefer to go with chunk upload on storage directory then move it to pCloud

Please or to participate in this conversation.