需要使用python中的Gridfs在Mongo数据库中存储/导入pdf文件(存在于本地目录中)。 我尝试了一些代码,但无法正常工作。 我尝试过:
public class Weatherapp extends AppCompatActivity {
static TextView ctemp;
static TextView ftemp;
static TextView ktemp;
static TextView location;
static TextView pressure;
static TextView humidity;
static TextView mintempc;
static TextView mintempf;
static TextView mintempk;
static TextView maxtempc;
static TextView maxtempf;
static TextView maxtempk;
static TextView sealevel;
static TextView groundlevel;
static TextView windspeed;
static Button refresh;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_weatherapp);
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Dowlode task = new Dowlode();
String provider = locationManager.getBestProvider(new Criteria(), false);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
Location locationn = locationManager.getLastKnownLocation(provider);
Double lat = locationn.getLatitude();
Double lng = locationn.getLongitude();
task.execute("https://samples.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=4ba583d5302c8723764443f9d6f08116");
ctemp = findViewById(R.id.ctemp);
ftemp = findViewById(R.id.ftemp);
ktemp = findViewById(R.id.ktemp);
location = findViewById(R.id.location);
pressure = findViewById(R.id.pressure);
humidity = findViewById(R.id.humidity);
mintempc = findViewById(R.id.mintempc);
mintempf = findViewById(R.id.mintempf);
mintempk = findViewById(R.id.mintempk);
maxtempc = findViewById(R.id.maxtempc);
maxtempf = findViewById(R.id.maxtempf);
maxtempk = findViewById(R.id.maxtempk);
sealevel = findViewById(R.id.sealevel);
groundlevel = findViewById(R.id.groundlevel);
windspeed = findViewById(R.id.windspeed);
refresh = findViewById(R.id.refresh);
}
所以请帮助我解决这些问题。我正在使用Python,gridfs