Coder Social home page Coder Social logo

Comments (8)

github-actions avatar github-actions commented on May 20, 2024

Please add a valid Rod Version: v0.0.0 to your issue. Current version is v0.114.5

generated by check-issue

from rod.

ysmood avatar ysmood commented on May 20, 2024

The WaitDownload method allows you to specify the dir:

rod/browser.go

Line 504 in d2ad7cb

func (b *Browser) WaitDownload(dir string) func() (info *proto.PageDownloadWillBegin) {

from rod.

sunaynat avatar sunaynat commented on May 20, 2024

if I specify in waitdownload then my file gets downloaded with alphanumeric characters and not with the original filename. And if I dont use waitdownload then it gets downloaded in downloads folder with the correct filename

from rod.

ysmood avatar ysmood commented on May 20, 2024

Then you need to config the preference of the browser to change the download folder:

func (l *Launcher) Preferences(pref string) *Launcher {

It's a json value like this:

flags.Preferences: {`{"plugins":{"always_open_pdf_externally": true}}`},

The doc of all preference:

https://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc?view=markup#l1443

from rod.

sunaynat avatar sunaynat commented on May 20, 2024

tried this, it did not work. Still it gets downloaded in downloads folder
launcher.New().Preferences({"download":{"default_directory": +mydir+}}).
Also tried with ""savefile":{"default_directory":"/Users/xyz/"}"
and savefile.default_directory

from rod.

ysmood avatar ysmood commented on May 20, 2024

Another way to find out the correct key is to check a real pref when you config the chrome with the browser's settings page, so you don't need to guess it

from rod.

sunaynat avatar sunaynat commented on May 20, 2024

savefile.default_directory this mentioned in doc

I added this preference also downloadPrefernce := "{"download.default_directory":"/Users/xyz/"}"
and tried with savefile as well but nothing is working. Also in prefernces file also I checked in my system, it doesn't update the file with any way I tried.

from rod.

ysmood avatar ysmood commented on May 20, 2024

Works fine to me:

package main

import (
	"github.com/go-rod/rod"
	"github.com/go-rod/rod/lib/launcher"
	"github.com/go-rod/rod/lib/utils"
)

func main() {
	pref := `{
  "download": {
    "default_directory": "/Users/yad/Downloads/ttt"
  }
}`

	l := launcher.New().Preferences(pref).Headless(false)

	u := l.MustLaunch()

	rod.New().ControlURL(u).MustConnect().MustPage()

	utils.Pause()
}

CleanShot 2023-12-21 at 14 24 05@2x

from rod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.