Perbaikan Nama FIle Google Drive
This commit is contained in:
@@ -606,7 +606,8 @@ class PengajuanAbsenController extends Controller
|
||||
$pegawai->nip,
|
||||
$pegawai->nama,
|
||||
$request->tanggal,
|
||||
$request->keterangan
|
||||
$request->keterangan,
|
||||
$namaFile
|
||||
);
|
||||
|
||||
if (! $linkDrive) {
|
||||
|
||||
@@ -21,7 +21,7 @@ class GoogleDriveService
|
||||
$this->rootFolderId = (string) config('services.google_drive.folder_id');
|
||||
}
|
||||
|
||||
public function uploadPdf(string $content, string $nip, string $namaPegawai, string $tanggal, string $namaKategori): string|false
|
||||
public function uploadPdf(string $content, string $nip, string $namaPegawai, string $tanggal, string $namaKategori, ?string $namaFile = null): string|false
|
||||
{
|
||||
if (! $this->credentialsPath || ! file_exists($this->credentialsPath) || ! $this->rootFolderId) {
|
||||
Log::error('GoogleDriveService: belum dikonfigurasi, upload dilewati.');
|
||||
@@ -30,7 +30,7 @@ class GoogleDriveService
|
||||
}
|
||||
|
||||
try {
|
||||
$client = new Client();
|
||||
$client = new Client;
|
||||
$client->setAuthConfig($this->credentialsPath);
|
||||
$client->addScope(Drive::DRIVE);
|
||||
|
||||
@@ -40,7 +40,7 @@ class GoogleDriveService
|
||||
$pegawaiFolderId = $this->findOrCreateFolder($service, $this->sanitize("$nip - $namaPegawai"), $pengajuanPresensiFolderId);
|
||||
$bulanFolderId = $this->findOrCreateFolder($service, Carbon::parse($tanggal)->translatedFormat('F Y'), $pegawaiFolderId);
|
||||
|
||||
$fileName = Carbon::parse($tanggal)->format('Y-m-d').'_'.$this->sanitize($namaKategori).'.pdf';
|
||||
$fileName = $namaFile ?? Carbon::parse($tanggal)->format('Y-m-d').'_'.$this->sanitize($namaKategori).'.pdf';
|
||||
|
||||
$fileMetadata = new DriveFile([
|
||||
'name' => $fileName,
|
||||
|
||||
Reference in New Issue
Block a user