In this letter, we consider a cooperative Internet of unmanned aerial vehicles (UAVs) in which the UAV collects data from ground sensors (GSs) and transmits the received data to the base station (BS) for further processing. The data at the UAV can either be transmitted directly to the BS via the cellular mode or be transmitted through the other UAV via the relay mode. The objective is to minimize the completion time for all the tasks by joint mode selection and trajectory optimization, which can be decoupled into a series of convex optimization problems. The simulation results show that the relay mode is more likely to be selected when the signal-to-noise ratio (SNR) threshold is higher than 10 dB. Otherwise, the UAV prefers to transmit in the cellular mode.